When I stop my RabbitMQ container, I expect the code to exit with an exception, because my close_callback raises one.
Instead the exception is silenced, and the code recovers when I run the container back.
I think it happens because CallbackCollection.__call__ adds all the async callbacks to futures list, and runs return asyncio.gather(*futures, return_exceptions=True).
From asyncio docs: If *return_exceptions* is True, exceptions in the tasks are treated the same as successful results, and gathered in the result list; otherwise, the first rasied exception will be immediately propagated to the returned future.
Connection._on_connection_close calls CallbackCollection.__call__, but does nothing with the return value, so the exceptions are ignored.
I have the following code:
When I stop my RabbitMQ container, I expect the code to exit with an exception, because my close_callback raises one. Instead the exception is silenced, and the code recovers when I run the container back.
I think it happens because
CallbackCollection.__call__
adds all the async callbacks to futures list, and runsreturn asyncio.gather(*futures, return_exceptions=True)
.From asyncio docs:
If *return_exceptions* is True, exceptions in the tasks are treated the same as successful results, and gathered in the result list; otherwise, the first rasied exception will be immediately propagated to the returned future.
Connection._on_connection_close
callsCallbackCollection.__call__
, but does nothing with the return value, so the exceptions are ignored.