Skip to content

Commit

Permalink
Use WeakSet for queues and exchanges in RobustChannel
Browse files Browse the repository at this point in the history
  • Loading branch information
mosquito committed May 11, 2023
1 parent 6805837 commit 663807c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions aio_pika/robust_channel.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import asyncio
from collections import defaultdict
from itertools import chain
from typing import Any, DefaultDict, Dict, Optional, Set, Type, Union
from typing import Any, DefaultDict, Dict, Optional, AbstractSet, Type, Union
from warnings import warn
from weakref import WeakSet

import aiormq

Expand All @@ -28,8 +29,8 @@ class RobustChannel(Channel, AbstractRobustChannel): # type: ignore
QUEUE_CLASS: Type[Queue] = RobustQueue
EXCHANGE_CLASS: Type[Exchange] = RobustExchange

_exchanges: DefaultDict[str, Set[AbstractRobustExchange]]
_queues: DefaultDict[str, Set[RobustQueue]]
_exchanges: DefaultDict[str, AbstractSet[AbstractRobustExchange]]
_queues: DefaultDict[str, AbstractSet[RobustQueue]]
default_exchange: RobustExchange

def __init__(
Expand Down Expand Up @@ -57,8 +58,8 @@ def __init__(
on_return_raises=on_return_raises,
)

self._exchanges = defaultdict(set)
self._queues = defaultdict(set)
self._exchanges = defaultdict(WeakSet)
self._queues = defaultdict(WeakSet)
self._prefetch_count: int = 0
self._prefetch_size: int = 0
self._global_qos: bool = False
Expand Down

0 comments on commit 663807c

Please sign in to comment.