Skip to content
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

Closed
zloyrusskiy opened this issue Dec 1, 2013 · 2 comments
Closed

Problem with exception handling in async mode #179

zloyrusskiy opened this issue Dec 1, 2013 · 2 comments

Comments

@zloyrusskiy
Copy link

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.

@zloyrusskiy
Copy link
Author

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

@michaelklishin
Copy link
Member

While the intent was certainly to catch all exceptions and not just Bunny::Exception, developers need to handle exceptions delivery processing may raise. Even if Bunny re-raises whatever it's caught, it happens on a thread that belongs to consumer work pool and there's little that can be done about it.

michaelklishin added a commit that referenced this issue Dec 1, 2013
michaelklishin added a commit that referenced this issue Dec 11, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants