benjamin-hodgson / asynqp

An AMQP library for asyncio
MIT License
84 stars 29 forks source link

Refactor the return handler #71

Open tvoinarovskyi opened 8 years ago

tvoinarovskyi commented 8 years ago

Currently the return handler ( Channel.set_return_handler ) has a strange default. From docs:

By default, an exception is raised, which will be handled by the event loop’s exception handler (see BaseEventLoop.set_exception_handler). If handler is None, this default behaviour is set.

This is bad practice, and the documentation should not recommend using BaseEventLoop.set_exception_handler it in any way. I think a null handler, that just logs the return is more sensible.

tvoinarovskyi commented 8 years ago

set_exception_handler is not a signal, it's a handler (ie we can't set multiple handlers, just override it). It's not designed to perform application logic, but for logging, alerting, etc. It should react on unexpected problems, rather than expected callbacks.