From: "Iñaki Baz Castillo" Date: 2012-06-13T18:26:54+09:00 Subject: Re: Thread#kill is not rescued by "rescue Exception" 2012/6/13 Tony Arcieri : > Seems good! > > I've exposed Thread#kill in my library (Celluloid) as a sort of last resort. > > As for Thread#raise, I think if you reraise the exception at the end of your > error handler after rescuing Exception when it isn't a StandardError, you > should be good Yes, during the libuv loop execution I execute all the Ruby callbacks with rb_protect(). If an exception/error occurs then I pass it (the exception object retrieved via rb_errinfo() function) to the "error handler" of my library which, in case it's a StandardError it would call the user provided block (optional) to react on errors. Otherwise (not a standard error) my library properly releases the libuv loop and re-raises the captured exception. The only "problem" is that, as said in my other mails, when the thread is killed with Thread#kill, rb_errinfo() returns Fixnum(8 = RUBY_TAG_FATAL) instead of an Exception object, so trying to raise a Fixnum is not a good idea :) And... it seems that all of this is due a bug in Ruby: http://bugs.ruby-lang.org/projects/ruby-trunk/repository/revisions/35622 http://bugs.ruby-lang.org/issues/5993 :) -- Iñaki Baz Castillo