diff --git a/utils/queues.py b/utils/queues.py index 583bcd1..edb5fa7 100644 --- a/utils/queues.py +++ b/utils/queues.py @@ -1,6 +1,6 @@ +from concurrent.futures import ThreadPoolExecutor import datetime import os -from threading import Thread import zoneinfo import requests import time @@ -13,6 +13,9 @@ else: QUEUES_URL = 'http://queues:1239' +executor = ThreadPoolExecutor(max_workers=1) + + class QueuesException(Exception): ... @@ -36,9 +39,7 @@ class TasksHandlerMixin: print(f'metric failed: {e}') def send_metric(self, start, success, end): - # Thread(target=self._send_metric, args=(start, success, end)).start() - # self._send_metric(start, success, end) - ... + executor.submit(self._send_metric, start, success, end) def poll(self): while True: