From 05475e727817b6aa481367ce6dff73672778fc77 Mon Sep 17 00:00:00 2001 From: SOSNE Date: Mon, 22 Jul 2024 22:33:02 +0200 Subject: [PATCH] Added check to ensure the connection is established. --- workers/summarizer.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/workers/summarizer.py b/workers/summarizer.py index da8ed31..2f47233 100644 --- a/workers/summarizer.py +++ b/workers/summarizer.py @@ -136,6 +136,11 @@ def start_summarizer(): connection = pika.BlockingConnection(connection_params) channel = connection.channel() while True: + if connection.is_open is False: + connection_params = pika.ConnectionParameters(host="rabbitmq", port=5672, heartbeat=600) + connection = pika.BlockingConnection(connection_params) + channel = connection.channel() + queue_length = len(task_queue) if queue_length > previous_queued_tasks: print(f"{Fore.CYAN}{Style.BRIGHT}--- SUMMARIZER ---")