From: Charles Nutter Date: 2011-01-19T06:51:01+09:00 Subject: [ruby-core:34575] [Ruby 1.9-Bug#4285] Ruby don't have asynchrounous exception safe syntax and It should have. Issue #4285 has been updated by Charles Nutter. It is not possible to make cross-thread exception-raising safe with current Ruby semantics. See the discussion on my blog post here: http://blog.headius.com/2008/02/rubys-threadraise-threadkill-timeoutrb.html No matter how many locks you use, there's always potential for an arbitrary thread to receive an exception or kill request while executing or immediately before "ensure" code. This breaks the contract of ensure. Ergo, asynchronous exceptions (exceptions thrown from one thread into another) and killable threads are inherently not possible to make safe if you want to obey the contract of "ensure". JRuby is affected by this as well, since we have to emulate MRI's asynchonous exception throwing features. There is a way to change Ruby semantics to make asynchronous exceptions and "kill" safe: do not allow them to terminate a thread running an ensure block until that block has completed. However, I think this is mostly useless; a top-level thread that fires logic in its ensure would prevent the entire thread from being killable or raiseable. Ultimately, both of these features should be removed. And I know that's not going to happen, because everyone uses them :) ---------------------------------------- http://redmine.ruby-lang.org/issues/show/4285 ---------------------------------------- http://redmine.ruby-lang.org