Project

General

Profile

Bug #9380

Enumerator does not work in timeout

Added by nobu (Nobuyoshi Nakada) over 4 years ago. Updated about 4 years ago.

Status:
Closed
Priority:
Normal
Target version:
[ruby-dev:47872]

Description

Enumeratortimeoutの組み合わせで、Timeout::Errorが起きるべきところでArgumentErrorが発生します。

$ ruby -v -rtimeout -e 'def (o=Object.new).each; sleep; end' -e 'Timeout.timeout(0.01) {o.to_enum.next}'
ruby 2.2.0dev (2014-01-07 trunk 44522) [universal.x86_64-darwin13.0]
/opt/local/lib/ruby/2.2.0/timeout.rb:39:in `throw': uncaught throw #<Timeout::ExitException: Timeout::ExitException> (ArgumentError)
    from /opt/local/lib/ruby/2.2.0/timeout.rb:39:in `exception'
    from -e:1:in `sleep'
    from -e:1:in `each'
    from -e:1:in `each'

Associated revisions

Revision 3e9e4a6a
Added by nobu (Nobuyoshi Nakada) over 4 years ago

lib/timeout.rb: fallback to Timeout::Error

  • lib/timeout.rb (Timeout::ExitException.catch): pass arguments for new instance.
  • lib/timeout.rb (Timeout::ExitException#exception): fallback to Timeout::Error if couldn't throw. [Bug #9380]
  • lib/timeout.rb (Timeout#timeout): initialize ExitException with message for the fallback case.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44523 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 44523
Added by nobu (Nobuyoshi Nakada) over 4 years ago

lib/timeout.rb: fallback to Timeout::Error

  • lib/timeout.rb (Timeout::ExitException.catch): pass arguments for new instance.
  • lib/timeout.rb (Timeout::ExitException#exception): fallback to Timeout::Error if couldn't throw. [Bug #9380]
  • lib/timeout.rb (Timeout#timeout): initialize ExitException with message for the fallback case.

Revision 44523
Added by nobu (Nobuyoshi Nakada) over 4 years ago

lib/timeout.rb: fallback to Timeout::Error

  • lib/timeout.rb (Timeout::ExitException.catch): pass arguments for new instance.
  • lib/timeout.rb (Timeout::ExitException#exception): fallback to Timeout::Error if couldn't throw. [Bug #9380]
  • lib/timeout.rb (Timeout#timeout): initialize ExitException with message for the fallback case.

Revision 44523
Added by nobu (Nobuyoshi Nakada) over 4 years ago

lib/timeout.rb: fallback to Timeout::Error

  • lib/timeout.rb (Timeout::ExitException.catch): pass arguments for new instance.
  • lib/timeout.rb (Timeout::ExitException#exception): fallback to Timeout::Error if couldn't throw. [Bug #9380]
  • lib/timeout.rb (Timeout#timeout): initialize ExitException with message for the fallback case.

Revision 44523
Added by nobu (Nobuyoshi Nakada) over 4 years ago

lib/timeout.rb: fallback to Timeout::Error

  • lib/timeout.rb (Timeout::ExitException.catch): pass arguments for new instance.
  • lib/timeout.rb (Timeout::ExitException#exception): fallback to Timeout::Error if couldn't throw. [Bug #9380]
  • lib/timeout.rb (Timeout#timeout): initialize ExitException with message for the fallback case.

Revision 44523
Added by nobu (Nobuyoshi Nakada) over 4 years ago

lib/timeout.rb: fallback to Timeout::Error

  • lib/timeout.rb (Timeout::ExitException.catch): pass arguments for new instance.
  • lib/timeout.rb (Timeout::ExitException#exception): fallback to Timeout::Error if couldn't throw. [Bug #9380]
  • lib/timeout.rb (Timeout#timeout): initialize ExitException with message for the fallback case.

Revision c00e2889
Added by naruse (Yui NARUSE) about 4 years ago

merge revision(s) 44517,44518,44519,44523: [Backport #9354]

* lib/timeout.rb (Timeout#timeout): when a custom exception is given,
  no instance is needed to be caught, so defer creating new instance
  until it is raised.   [Bug #9354]

* lib/timeout.rb (Timeout#timeout): should not rescue ordinarily
  raised ExitException, which should not be thrown.

* lib/timeout.rb (Timeout::ExitException.catch): set @thread only if
  it ought to be caught.

* lib/timeout.rb (Timeout::ExitException.catch): pass arguments
  for new instance.

* lib/timeout.rb (Timeout::ExitException#exception): fallback to
  Timeout::Error if couldn't throw.   [Bug #9380]

* lib/timeout.rb (Timeout#timeout): initialize ExitException with
  message for the fallback case.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44841 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

History

#1 [ruby-dev:47873] Updated by nobu (Nobuyoshi Nakada) over 4 years ago

  • Description updated (diff)

#2 Updated by nobu (Nobuyoshi Nakada) over 4 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r44523.
Nobuyoshi, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


lib/timeout.rb: fallback to Timeout::Error

  • lib/timeout.rb (Timeout::ExitException.catch): pass arguments for new instance.
  • lib/timeout.rb (Timeout::ExitException#exception): fallback to Timeout::Error if couldn't throw. [Bug #9380]
  • lib/timeout.rb (Timeout#timeout): initialize ExitException with message for the fallback case.

#3 [ruby-dev:47874] Updated by nobu (Nobuyoshi Nakada) over 4 years ago

  • Backport changed from 1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN to 1.9.3: DONTNEED, 2.0.0: DONTNEED, 2.1: REQUIRED

#4 Updated by nobu (Nobuyoshi Nakada) over 4 years ago

  • Description updated (diff)

#5 [ruby-dev:47990] Updated by naruse (Yui NARUSE) about 4 years ago

  • Backport changed from 1.9.3: DONTNEED, 2.0.0: DONTNEED, 2.1: REQUIRED to 1.9.3: DONTNEED, 2.0.0: DONTNEED, 2.1: DONE

Also available in: Atom PDF