Compare commits

..

No commits in common. "08bc931a5a9e8213570c7e4ff7f1e0d3fb3adeb2" and "fbc9c0e0d7b4d5a8053e339d5fbb46c587d0497c" have entirely different histories.

View File

@ -1,7 +1,6 @@
from concurrent.futures import ThreadPoolExecutor
import datetime
import os
import zoneinfo
from threading import Thread
import requests
import time
@ -13,9 +12,6 @@ else:
QUEUES_URL = 'http://queues:1239'
executor = ThreadPoolExecutor(max_workers=1)
class QueuesException(Exception):
...
@ -39,7 +35,8 @@ class TasksHandlerMixin:
print(f'metric failed: {e}')
def send_metric(self, start, success, end):
executor.submit(self._send_metric, start, success, end)
# Thread(target=self._send_metric, args=(start, success, end)).start()
self._send_metric(start, success, end)
def poll(self):
while True:
@ -53,14 +50,14 @@ class TasksHandlerMixin:
if not task:
time.sleep(0.2)
continue
start = datetime.datetime.now().astimezone(zoneinfo.ZoneInfo("Europe/Moscow"))
start = datetime.datetime.now()
try:
self.process(task['payload'])
success = True
except Exception as exc:
print(f'Error processing message id={task["id"]}, payload={task["payload"]}, exc={exc}')
success = False
end = datetime.datetime.now().astimezone(zoneinfo.ZoneInfo("Europe/Moscow"))
end = datetime.datetime.now()
try:
resp = requests.post(f'{QUEUES_URL}/api/v1/finish', json={'id': task['id']})
if resp.status_code != 202: