Set closing future result
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.
@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.
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
#218 looks good, thanks!