New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with exception handling in async mode #179
Comments
some example: conn = Bunny.new CONFIG[:rmq]
conn.start
ch = conn.create_channel
5.times.each do |n|
q = ch.queue 'rpc' + n.to_s
q.subscribe do |delivery_info, properties, payload|
puts " [x] (rpc#{n}) #{payload}"
some_misprint
end
end
loop do
Thread.list.each do |t|
puts "#{t.inspect} - #{t.status}"
end
puts "\n\n#{Time.now} - #{Thread.list.length } - \n\n"
sleep 1
end When any of subscribers gets message will be error (and one thread dies), because there is no method "some_misprint". But we don't know about it and processing other subscribers will be broken, but program will be responsive. We can see normal error processing if add before all code: module Bunny
remove_const :Exception
end |
While the intent was certainly to catch all exceptions and not just |
At lib/bunny/consumer_work_pool.rb:85 there is catching of Exception, but it doesn't work with NameError(misprint in code), and it kill thread silently and there is no exception, bacause needed join of crashed thread to show exception (non blocking threads raising exceptions only after join).
I suggest to reraise all exceptions other than Bunny::Exception (or use raise ::Exception => e), because current behavior leads to errors that very hard to troubleshoot.
The text was updated successfully, but these errors were encountered: