Skip to content
Snippets Groups Projects
Commit 285882c1 authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

SW-827: make sure that the BusListenerJanitor always deletes the buslistener's queue

parent 703a2d9a
No related branches found
No related tags found
2 merge requests!74Lofar release 4 0,!71Resolve SW-827
...@@ -1621,19 +1621,31 @@ class BusListenerJanitor: ...@@ -1621,19 +1621,31 @@ class BusListenerJanitor:
def __enter__(self) -> BusListener: def __enter__(self) -> BusListener:
"""enter the context, and make the bus_listener start listening. """enter the context, and make the bus_listener start listening.
:return a reference to the buslistener, not to the janitor!""" :return a reference to the buslistener, not to the janitor!"""
self._bus_listener.start_listening() try:
return self._bus_listener self.open()
return self._bus_listener
except Exception as e:
logger.exception(e)
self.close()
raise
def __exit__(self, exc_type, exc_val, exc_tb): def __exit__(self, exc_type, exc_val, exc_tb):
"""leave the context, make the bus_listener stop listening, """leave the context, make the bus_listener stop listening,
and clean up the auto-generated queue""" and clean up the auto-generated queue"""
self.close()
def open(self):
"""make the bus_listener start listening."""
self._bus_listener.start_listening()
def close(self):
"""make the bus_listener stop listening, and delete listener queue"""
try: try:
bus_listener_address = self._bus_listener.address
self._bus_listener.stop_listening() self._bus_listener.stop_listening()
except Exception as e:
logger.error(e)
finally: finally:
logger.info("BusListenerJanitor deleting auto-generated queue: %s", self._bus_listener.address) logger.info("BusListenerJanitor deleting auto-generated queue: %s", bus_listener_address)
delete_queue(self._bus_listener.address) delete_queue(bus_listener_address)
# do not expose create/delete_queue/exchange etc methods in all, it's not part of the public API # do not expose create/delete_queue/exchange etc methods in all, it's not part of the public API
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment