Skip to content
Snippets Groups Projects
Commit 33ac4931 authored by Erik Reid's avatar Erik Reid
Browse files

bugfix for routing keys introduced in mypy refactoring

parent d8dd3e22
Branches
Tags
No related merge requests found
...@@ -74,7 +74,7 @@ def setup_channel( ...@@ -74,7 +74,7 @@ def setup_channel(
queue_declare: bool = True, queue_declare: bool = True,
exclusive: bool = False, exclusive: bool = False,
single_active_consumer: bool = False, single_active_consumer: bool = False,
routing_keys: str | Sequence[str | None] | None = None, routing_keys: Sequence[str] = [],
prefetch_count: int | None = None, prefetch_count: int | None = None,
force_quorum_queue: bool = False, force_quorum_queue: bool = False,
) -> tuple[BlockingChannel, str | None]: ) -> tuple[BlockingChannel, str | None]:
...@@ -142,8 +142,11 @@ def setup_channel( ...@@ -142,8 +142,11 @@ def setup_channel(
assert queue_name, "queue name must not be empty here" assert queue_name, "queue name must not be empty here"
if routing_keys is None or isinstance(routing_keys, str): if not routing_keys:
routing_keys = [routing_keys] # in case no routing keys are provided (as for fanout exchanges),
# ensure the queue is still bound to the exchange
routing_keys = [None]
for rk in routing_keys: for rk in routing_keys:
channel.queue_bind(exchange=exchange_name, queue=queue_name, routing_key=rk) channel.queue_bind(exchange=exchange_name, queue=queue_name, routing_key=rk)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment