H
hemant
In following code, both methos get_client_symbol and sync_clients gets
called and they start their own new threads. Now, what I would like to
do is, whenever a exception is raised from the nested threads..i would
like to catch them in the toplevel thread.
Now..I have tried many things:
Thread.abort_on_exception = true
and using just rescue or rescue Exception or rescue RuntimeError,
however the exception raised in nested threads won't get caught in the
top level thread. Any clues?
@threads << Thread.new do
child_threads = []
begin
child_threads << get_client_symbol(temp_client_id)
child_threads << sync_clients(temp_client_id)
child_threads.each {|thr| p thr.to_s; thr.join; }
rescue Exception
p $!
p $!.backtrace
# delete the values from list
@connected_clients.synchronize do
@connected_clients.delete(temp_client_id)
@symbols_being_added.signal
end #end of sync
child_threads.each {|thr| Thread.kill(thr) if thr.alive? }
end
end #end of threads
called and they start their own new threads. Now, what I would like to
do is, whenever a exception is raised from the nested threads..i would
like to catch them in the toplevel thread.
Now..I have tried many things:
Thread.abort_on_exception = true
and using just rescue or rescue Exception or rescue RuntimeError,
however the exception raised in nested threads won't get caught in the
top level thread. Any clues?
@threads << Thread.new do
child_threads = []
begin
child_threads << get_client_symbol(temp_client_id)
child_threads << sync_clients(temp_client_id)
child_threads.each {|thr| p thr.to_s; thr.join; }
rescue Exception
p $!
p $!.backtrace
# delete the values from list
@connected_clients.synchronize do
@connected_clients.delete(temp_client_id)
@symbols_being_added.signal
end #end of sync
child_threads.each {|thr| Thread.kill(thr) if thr.alive? }
end
end #end of threads