Implementacion mas completa de email y api para ingresar datos

This commit is contained in:
2020-11-16 23:33:49 -03:00
parent 1b57d705bb
commit 2d157f6989
14 changed files with 369 additions and 112 deletions

View File

@ -3,6 +3,7 @@ import datetime
import locale
from threading import Thread
import queue
from src.functions import dump_queue
def get_today(tz):
@ -83,12 +84,11 @@ class Logger:
class Worker(Thread):
def __init__(self, params, configs):
super().__init__()
self.event = params['events']['stop']
self.event = params['events']['log_stop']
self.queue = params['queues']['log']
self.wait = configs.get('supervisor.wait')
self.logger = Logger(params['folders']['log'], configs.get('timezone'), params['logger']['name'])
self.logging = params['logging']
self.queue.put({'is_start': True})
def parse_message(self, message):
if 'is_start' in message and message['is_start']:
@ -110,6 +110,7 @@ class Worker(Thread):
def run(self):
self.logging.log('Starting', caller=type(self))
self.queue.put({'is_start': True})
while not self.event.is_set():
try:
message = self.queue.get(timeout=self.wait)
@ -117,13 +118,6 @@ class Worker(Thread):
self.parse_message(message)
except queue.Empty:
continue
while True:
try:
message = self.queue.get(timeout=self.wait)
self.logging.log('Logger received message', caller=type(self))
self.parse_message(message)
except queue.Empty:
break
[self.parse_message(message) for message in dump_queue(self.queue, self.wait)]
self.logger.stop_log()
self.logging.log('Exiting', caller=type(self))
return