Issue #7088 has been reported by rklemme (Robert Klemme). ---------------------------------------- Bug #7088: Documentation of Timeout::timeout is wrong about which thread executes the block https://bugs.ruby-lang.org/issues/7088 Author: rklemme (Robert Klemme) Status: Open Priority: Normal Assignee: Category: Target version: ruby -v: ruby 1.9.3p194 (2012-04-20) [i686-linux] See http://rubydoc.info/stdlib/timeout/Timeout#timeout... - it reads "The block will be executed on another thread and will be given one argument: sec." If you make the source code visible or look into the file timeout.rb in the library you'll see that the block is invoked from the current (calling) thread. The comment reads as if the author had wanted to do an implementation like this: def timeout_1(timeout, &code) raise ArgumentError, "Invalid timeout: %p" % [timeout] unless timeout > 0 raise ArgumentError, "No code to execute" if code.nil? worker = Thread.new(&code) worker.join(timeout) and worker.value end Note: this avoids bug #4285 at the expense of a potentially longer running thread. Killing the background thread would suffer the same issues.
[ruby-trunk - Bug #7088][Open] Documentation of Timeout::timeout is wrong about which thread execute
on 2012-09-29 18:01
on 2012-09-29 18:33
Issue #7088 has been updated by drbrain (Eric Hodel). Category set to DOC Target version set to 2.0.0 ---------------------------------------- Bug #7088: Documentation of Timeout::timeout is wrong about which thread executes the block https://bugs.ruby-lang.org/issues/7088#change-29795 Author: rklemme (Robert Klemme) Status: Open Priority: Normal Assignee: Category: DOC Target version: 2.0.0 ruby -v: ruby 1.9.3p194 (2012-04-20) [i686-linux] See http://rubydoc.info/stdlib/timeout/Timeout#timeout... - it reads "The block will be executed on another thread and will be given one argument: sec." If you make the source code visible or look into the file timeout.rb in the library you'll see that the block is invoked from the current (calling) thread. The comment reads as if the author had wanted to do an implementation like this: def timeout_1(timeout, &code) raise ArgumentError, "Invalid timeout: %p" % [timeout] unless timeout > 0 raise ArgumentError, "No code to execute" if code.nil? worker = Thread.new(&code) worker.join(timeout) and worker.value end Note: this avoids bug #4285 at the expense of a potentially longer running thread. Killing the background thread would suffer the same issues.
on 2012-10-06 21:41
Issue #7088 has been updated by zzak (Zachary Scott). Assignee set to zzak (Zachary Scott) ---------------------------------------- Bug #7088: Documentation of Timeout::timeout is wrong about which thread executes the block https://bugs.ruby-lang.org/issues/7088#change-30127 Author: rklemme (Robert Klemme) Status: Open Priority: Normal Assignee: zzak (Zachary Scott) Category: DOC Target version: 2.0.0 ruby -v: ruby 1.9.3p194 (2012-04-20) [i686-linux] See http://rubydoc.info/stdlib/timeout/Timeout#timeout... - it reads "The block will be executed on another thread and will be given one argument: sec." If you make the source code visible or look into the file timeout.rb in the library you'll see that the block is invoked from the current (calling) thread. The comment reads as if the author had wanted to do an implementation like this: def timeout_1(timeout, &code) raise ArgumentError, "Invalid timeout: %p" % [timeout] unless timeout > 0 raise ArgumentError, "No code to execute" if code.nil? worker = Thread.new(&code) worker.join(timeout) and worker.value end Note: this avoids bug #4285 at the expense of a potentially longer running thread. Killing the background thread would suffer the same issues.
on 2012-10-11 20:29
Issue #7088 has been updated by zzak (Zachary Scott). How about we change that to: "The block will be executed on the current thread and will be given one argument: sec. While, the timer for sec number of seconds will run in another thread". ---------------------------------------- Bug #7088: Documentation of Timeout::timeout is wrong about which thread executes the block https://bugs.ruby-lang.org/issues/7088#change-30327 Author: rklemme (Robert Klemme) Status: Open Priority: Normal Assignee: zzak (Zachary Scott) Category: DOC Target version: 2.0.0 ruby -v: ruby 1.9.3p194 (2012-04-20) [i686-linux] See http://rubydoc.info/stdlib/timeout/Timeout#timeout... - it reads "The block will be executed on another thread and will be given one argument: sec." If you make the source code visible or look into the file timeout.rb in the library you'll see that the block is invoked from the current (calling) thread. The comment reads as if the author had wanted to do an implementation like this: def timeout_1(timeout, &code) raise ArgumentError, "Invalid timeout: %p" % [timeout] unless timeout > 0 raise ArgumentError, "No code to execute" if code.nil? worker = Thread.new(&code) worker.join(timeout) and worker.value end Note: this avoids bug #4285 at the expense of a potentially longer running thread. Killing the background thread would suffer the same issues.
on 2012-10-11 22:06
Issue #7088 has been updated by drbrain (Eric Hodel). I think deleting the paragraph would be sufficient. We don't need to reveal the implementation details of timeout. ---------------------------------------- Bug #7088: Documentation of Timeout::timeout is wrong about which thread executes the block https://bugs.ruby-lang.org/issues/7088#change-30332 Author: rklemme (Robert Klemme) Status: Open Priority: Normal Assignee: zzak (Zachary Scott) Category: DOC Target version: 2.0.0 ruby -v: ruby 1.9.3p194 (2012-04-20) [i686-linux] See http://rubydoc.info/stdlib/timeout/Timeout#timeout... - it reads "The block will be executed on another thread and will be given one argument: sec." If you make the source code visible or look into the file timeout.rb in the library you'll see that the block is invoked from the current (calling) thread. The comment reads as if the author had wanted to do an implementation like this: def timeout_1(timeout, &code) raise ArgumentError, "Invalid timeout: %p" % [timeout] unless timeout > 0 raise ArgumentError, "No code to execute" if code.nil? worker = Thread.new(&code) worker.join(timeout) and worker.value end Note: this avoids bug #4285 at the expense of a potentially longer running thread. Killing the background thread would suffer the same issues.
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.