Skip to content

Commit

Permalink
Code review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
saville committed Feb 16, 2021
1 parent 2874064 commit 232c1f4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 2 additions & 4 deletions docs/source/examples/pooling-recycled.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from collections import defaultdict

import asyncio
import aio_pika
from aio_pika.pool import Pool
Expand All @@ -12,8 +10,8 @@ class NonRestoringRobustChannel(aio_pika.RobustChannel):
"""
async def reopen(self) -> None:
# Clear out exchanges and queues when reopened
self._exchanges = defaultdict(set)
self._queues = defaultdict(set)
self._exchanges.clear()
self._queues.clear()
await super().reopen()


Expand Down
7 changes: 7 additions & 0 deletions docs/source/quick-start.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,12 @@ Connection pooling
Connection pooling with recycled channels
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

When channels are re-used from a pool where queues and exchanges are not
consistent (i.e. the first time a channel is checked out it creates and uses
queue1 and the next time it is checked out it creates and uses queue2), it
is necessary to clear queues and exchanges before attempting to use the
channel. This is done with custom Connection and Channel classes and by
calling ``reopen`` on channel checkout if it was closed.

.. literalinclude:: examples/pooling-recycled.py
:language: python

0 comments on commit 232c1f4

Please sign in to comment.