Skip to content
Snippets Groups Projects

Shutdown igwn-alert listener properly

Merged Deep Chatterjee requested to merge deep.chatterjee/gwcelery:stop-listener-properly into main
All threads resolved!
1 file
+ 5
4
Compare changes
  • Side-by-side
  • Inline
@@ -10,7+10,7 @@
from igwn_alert import client
from .signals import igwn_alert_received
__all__ = ('Receiver',)
log = get_logger(__name__)
@@ -21,7+21,7 @@
super().__init__(*args, **kwargs)
self.batch_size = 1
self.until_eos = True
self.shutdown = False
self.running = False
self.start_at = StartPosition.LATEST
# mostly implemented from https://git.ligo.org/computing/igwn-alert/client/-/blob/main/igwn_alert/client.py # noqa: E501
def listen(self, callback=None, topic=None):
self.running = True
if topic:
if isinstance(topic, str):
topic = [topic]
@@ -55,7 +56,7 @@ class IGWNAlertClient(client):
callback(topic=metadata.topic.split('.')[1],
payload=payload)
except (KeyboardInterrupt, SystemExit):
self.shutdown = True
self.running = False
s.close()
@@ -99,8 +100,8 @@ class Receiver(IGWNAlertBootStep):
def stop(self, consumer):
super().stop(consumer)
self._client.shutdown = True
self.thread.join()
self._client.running = False
self.thread.join(timeout=10)
def info(self, consumer):
return {'igwn-alert-topics': consumer.app.conf[
Loading