Skip to content

Commit

Permalink
Change logic about exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel-piles committed Sep 16, 2024
1 parent 6f6815b commit 4e202dc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ def process_function(task_message):
result_message['processed'] = True
return result_message

queue_processor = QueueProcessor(redis_host="localhost", redis_port=6379, queues_names_by_priority=["test_queue_1", "test_queue_2"])
queue_processor = QueueProcessor(redis_host="localhost", redis_port=6379, queues_names_by_priority=["test_queue_1", "test_queue_2"], logger=service_logger)
queue_processor.start()

print("the process stopped unexpectedly")
```
4 changes: 2 additions & 2 deletions src/queue_processor/QueueProcessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ def start(self, process: callable):

results = process(message["message"])
self.get_queue(results_queue_name).sendMessage().message(results).execute()
except NoMessageInQueue:
sleep(2)
except redis.exceptions.ConnectionError:
self.queue_processor_logger.error(f"Error connecting to Redis: {self.redis_host}:{self.redis_port}")
sleep(30)
except NoMessageInQueue:
sleep(2)
except Exception as e:
self.queue_processor_logger.error(f"Error: {e}", exc_info=True)
sleep(60)

0 comments on commit 4e202dc

Please sign in to comment.