Hmm. Question.
Imagine you’ve got this code:
a = Thread.new {
begin
do stuff
rescue MyException
end
}
a.raise MyException.new
Is it possible that this will still result in an uncaught exception
within thread a? Thoughts?
Thank you!
-Roger
Hmm. Question.
Imagine you’ve got this code:
a = Thread.new {
begin
rescue MyException
end
}
a.raise MyException.new
Is it possible that this will still result in an uncaught exception
within thread a? Thoughts?
Thank you!
-Roger
On Wed, Sep 05, 2007 at 06:47:29AM +0900, Roger P. wrote:
Is it possible that this will still result in an uncaught exception
within thread a? Thoughts?
Thank you!
-RogerPosted via http://www.ruby-forum.com/.
Thread#raise is bad, in general, for worse reasons than that:
t = Thread.new {
begin
allocate_resource()
do_something()
ensure
cleanup_resource()
end
}
sleep 1
t.raise SomeException.new
If the thread is in cleanup when Thread#raise is called, then cleanup
will fail, which is probably not the desired behavior.
There are plenty other examples I’ve seen as well.
Paul
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs