Bug #9380

Enumerator does not work in timeout

Added by Nobuyoshi Nakada over 1 year ago. Updated over 1 year ago.

[ruby-dev:47872]
Status:Closed
Priority:Normal
Assignee:Nobuyoshi Nakada
ruby -v:r44522 Backport:1.9.3: DONTNEED, 2.0.0: DONTNEED, 2.1: DONE

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 44523
Added by Nobuyoshi Nakada over 1 year 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 Nobuyoshi Nakada over 1 year 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.

History

#1 Updated by Nobuyoshi Nakada over 1 year ago

  • Description updated (diff)

#2 Updated by Nobuyoshi Nakada over 1 year 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 Updated by Nobuyoshi Nakada over 1 year 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 Nobuyoshi Nakada over 1 year ago

  • Description updated (diff)

#5 Updated by Yui NARUSE over 1 year 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