Skip to content

Commit

Permalink
More logging for firhose data stream termination
Browse files Browse the repository at this point in the history
  • Loading branch information
richardr1126 committed Dec 5, 2024
1 parent 01e8c12 commit 2817a6e
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions start_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,27 @@
import signal

from utils import config
from utils.logger import logger
import firehose.data_stream as data_stream
from firehose.data_filter import operations_callback

def main():
stream_stop_event = threading.Event()

def sigint_handler(*_):
print('Stopping data stream...')
def handle_termination(signum, frame):
logger.info(f'Received termination signal {signum}. Stopping firehose stream...')
stream_stop_event.set()
sys.exit(0)

signal.signal(signal.SIGINT, sigint_handler)
for sig in [signal.SIGINT, signal.SIGTERM, signal.SIGHUP]:
signal.signal(sig, handle_termination)

data_stream.run(config.SERVICE_DID, operations_callback, stream_stop_event)
try:
data_stream.run(config.SERVICE_DID, operations_callback, stream_stop_event)
except Exception as e:
logger.error(f"An exception occurred in the firehose: {e}")
sys.exit(1)

if __name__ == '__main__':
main()

0 comments on commit 2817a6e

Please sign in to comment.