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

Fix bug with RPC when handling on_close with a RobustConnection #573

Closed CodeCorrupt closed 10 months ago

CodeCorrupt commented 10 months ago

When handing on_close, futures were not properly popped from the futures list, causing an asyncio.exceptions.InvalidStateError when the connection is re-established and the response received.

CodeCorrupt commented 10 months ago

Alternatively, the futures could be popped by changing this loop to use enumerate(self.futures), then pop using the correlation_id, and then just deleting the self.futures.pop(str(id(future)), None) line. But the PR I submitted seemed like a more general solution to me

coveralls commented 10 months ago

Coverage Status

coverage: 88.241% (-0.08%) from 88.322% when pulling e951c72b7192c8bb4a1f14c914c6a72361fe8d7d on CodeCorrupt:master into c8e33c58ff7b81c6eeff58fcaf8c44ded82f9bce on mosquito:master.

mosquito commented 10 months ago

@CodeCorrupt I was thinking, the on_close is called quite rarely, maybe it makes sense to copy the whole sequence there so I don't have to do it every time here?

mosquito commented 10 months ago

@CodeCorrupt released in 9.2.2