aiormq icon indicating copy to clipboard operation
aiormq copied to clipboard

Set closing future result

Open unkcpz opened this issue 1 year ago • 1 comments

resolve deadlock when closing the connection.

I got the problem from aio-pika when closing the connection, the closing is always end up with timeout. I narrow down the problem to aiormq that the callbacks (which is _on_connection_close method of aio_pika.Connection class) of UnderlayConnection as the transport of Connection was never got chances to run. The callbacks are triggered by self.closing.add_done_callback(close_callback), but in aiormq where the self.closing defined, it never get result resolved.

The change I did here is to set result of self.closing future as the last step of closing a connection so that all the attached callbacks get chance to run after.

unkcpz avatar Dec 20 '24 10:12 unkcpz

@mosquito I guess this is a bug, can you have a look at it? It can solve the issue of https://github.com/mosquito/aio-pika/issues/640.

unkcpz avatar Dec 20 '24 11:12 unkcpz

Thank you for your contribution. I have merge this but I have to little bit modify this code for passing an exception to closing future. See more to #218

mosquito avatar Oct 20 '25 10:10 mosquito

#218 looks good, thanks!

unkcpz avatar Oct 21 '25 05:10 unkcpz