fix
This commit is contained in:
parent
e0e7564fcc
commit
72c5823ccd
@ -13,14 +13,15 @@ else:
|
||||
QUEUES_URL = 'http://queues:1239'
|
||||
|
||||
|
||||
executor = ThreadPoolExecutor(max_workers=4)
|
||||
|
||||
|
||||
class QueuesException(Exception):
|
||||
...
|
||||
|
||||
|
||||
class TasksHandlerMixin:
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.executor = ThreadPoolExecutor(max_workers=4)
|
||||
|
||||
def _send_metric(self, start: datetime.datetime, end: datetime.datetime, success: bool):
|
||||
try:
|
||||
resp = requests.post('http://monitoring:1237/api/v1/metrics/task', json={
|
||||
@ -39,10 +40,6 @@ class TasksHandlerMixin:
|
||||
except Exception as e:
|
||||
print(f"Error sending metric: {e}")
|
||||
|
||||
def send_metric(self, start: datetime.datetime, end: datetime.datetime, success: bool):
|
||||
executor.submit(self._send_metric, start, end, success)
|
||||
# self._send_metric(start, end, success)
|
||||
|
||||
def poll(self):
|
||||
while True:
|
||||
try:
|
||||
@ -70,7 +67,7 @@ class TasksHandlerMixin:
|
||||
raise QueuesException
|
||||
except:
|
||||
print(f'Failed to finish task id={task["id"]}')
|
||||
self.send_metric(start, end, success)
|
||||
self.executor.submit(self._send_metric, start, end, success)
|
||||
|
||||
@property
|
||||
def queue_name(self):
|
||||
|
Loading…
Reference in New Issue
Block a user