Polyconseil / aioamqp

AMQP implementation using asyncio
Other
280 stars 88 forks source link

Add cancellation exception handler #125

Open progovoy opened 7 years ago

progovoy commented 7 years ago

This commit handles a proper close of the connection with MQ broker on an outside cancellation of the future. For instance when calling cancel on all of the loop's gathered futures on program termination, the library would just raise an exception.

hellysmile commented 7 years ago

Hello there, I was experiencing some kind of similar issues, as for me if library catches asycnio.CancelledError it needs to do internal cleanup and raise again asycnio.CancelledError, otherwise it will incorrect behavio for all nested coroutines. Right now I am using asyncio.shield for any aioamqp channel methods, cuz cancellation of them breaks all actually

progovoy commented 7 years ago

So you say we should re-raise the cancel exception after cleanup?

hellysmile commented 7 years ago

@progovoy it is up to @Polyconseil, and I am guessing to catch in same way with re-raise asyncio.Timeout

progovoy commented 7 years ago

ok so @Polyconseil, please let us know how to proceed. I can add the re-raise or you do. Thank you Victor!

progovoy commented 7 years ago

@hellysmile How should we proceed?