From d6a960ecdc8dbb8b76eac2953f755d2feaa1fb3b Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Tue, 3 Dec 2019 16:31:13 +0100 Subject: [PATCH] Auto-delete queues when the last consumer using them unsubscribes Fixes #20 --- libmozevent/pulse.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libmozevent/pulse.py b/libmozevent/pulse.py index ffaef99..a1ab60b 100644 --- a/libmozevent/pulse.py +++ b/libmozevent/pulse.py @@ -64,14 +64,17 @@ async def create_pulse_listener( # pulse but something we started doing in release services queue = f"queue/{user}/exchange/{exchange_name}" - await channel.queue_declare(queue_name=queue, durable=True) + await channel.queue_declare(queue_name=queue, durable=True, auto_delete=True) # in case we are going to listen to an exchange that is specific for this # user, we need to ensure that exchange exists before first message is # sent (this is what creates exchange) if exchange.startswith(f"exchange/{user}/"): await channel.exchange_declare( - exchange_name=exchange, type_name="topic", durable=True + exchange_name=exchange, + type_name="topic", + durable=True, + auto_delete=True, ) for topic in topics: