From: Sonny Chee Date: 2007-03-30T14:06:52+09:00 Subject: Exceptions occassionally lost by child threads Hey Guys, As I understand it, the correct way to pass exceptions between threads is to explicitly raise them in the target thread... so something like this works: a = Thread.new(Thread.current) { |parent| .... parent.raise err } What I'm curious about is that the following code also seems to work: a = Thread.new { begin puts 'blue' sleep 2; raise ArgumentError.new('green') rescue Exception => err puts "Caught: #{err.message}" raise err end } begin while a sleep 1 a = a.join(1) end puts 'yellow' rescue Exception => err puts "Caught it again: #{err.message}" end #blue #Caught: green #Caught it again: green However, if i move the sleep 1 statement to after a = a.join(1), the exception seems to get lost and the output is: #blue #Caught: green #yellow Should exceptions automatically propagate from children up to the parent? And if so, why should the positioning of something as innocuous as sleep 1 matter? Sonny. -- Posted via http://www.ruby-forum.com/.