mosquito / aio-pika

AMQP 0.9 client designed for asyncio and humans.
https://aio-pika.readthedocs.org/
Apache License 2.0
1.18k stars 186 forks source link

`RobustChannel` may fail to restore queues due to `WeakSet` #594

Open Dreamsorcerer opened 8 months ago

Dreamsorcerer commented 8 months ago

We've been using the robust channels, but we also use queue.consume() to set up a callback. After this, there is no obvious reason we would need to hold a reference to the queue.

Then when the connection fails, it tries to restore the queues at: https://github.com/mosquito/aio-pika/blob/master/aio_pika/robust_channel.py#L134-L135

In our application, it seems that one of the queues has always disappeared. I assume that on disconnection, the queue ends getting garbage-collected and removed from the set, as we don't keep any references to it in our code.

Maybe it would be a good idea to revisit whether WeakSet is a good idea here? Or, atleast add a warning to the .consume() documentation.