add func parm type

This commit is contained in:
2025-07-12 17:33:38 +02:00
parent b1ce9061b1
commit 7edaef3563
32 changed files with 301 additions and 75 deletions

View File

@@ -16,16 +16,16 @@ from utils.csv.loaders import get_next_csv_atomic
# Crea una context variable per identificare il worker
worker_context = contextvars.ContextVar('worker_id', default='00')
worker_context = contextvars.ContextVar('worker_id', default='^-^')
# Formatter personalizzato che include il worker_id
class WorkerFormatter(logging.Formatter):
"""Formatter personalizzato che include l'ID del worker nei log."""
def format(self, record):
def format(self, record: str) -> str:
"""Formatta il record di log includendo l'ID del worker.
Args:
record: Il record di log da formattare.
record (str): Il record di log da formattare.
Returns:
La stringa formattata del record di log.
@@ -41,7 +41,7 @@ ELAB_PROCESSING_DELAY = 0.2
# Tempo di attesa se non ci sono record da elaborare
NO_RECORD_SLEEP = 60
async def worker(worker_id: int, cfg: object, pool) -> None:
async def worker(worker_id: int, cfg: object, pool: object) -> None:
"""Esegue il ciclo di lavoro per l'elaborazione dei dati caricati.
Il worker preleva un record dal database che indica dati pronti per
@@ -51,10 +51,10 @@ async def worker(worker_id: int, cfg: object, pool) -> None:
Args:
worker_id (int): L'ID univoco del worker.
cfg (object): L'oggetto di configurazione.
pool: Il pool di connessioni al database.
pool (object): Il pool di connessioni al database.
"""
# Imposta il context per questo worker
worker_context.set(f"W{worker_id}")
worker_context.set(f"W{worker_id:02d}")
debug_mode = (logging.getLogger().getEffectiveLevel() == logging.DEBUG)
logger.info("Avviato")