@@ -292,7 +292,7 @@ def _process(self, func, item, *args, **kwargs):
292292 self ._failure_data .append (item )
293293
294294 def get_status (self ):
295- return f"{ round (self .total_processed / (time .time () - self ._started_at ), 2 )} cpf/s " \
295+ return f"{ round (self .total_processed / (time .monotonic () - self ._started_at ), 2 )} cpf/s " \
296296 f"- processing: { self .in_progress_count } " \
297297 f"- success: { self ._total_success } " \
298298 f"- fail: { len (self ._failure_data )} "
@@ -305,7 +305,7 @@ def process(self, func, data, *args, **kwargs):
305305 self ._stopped = False
306306 # inicia thread para atualizar o banco com o resultado da validação.
307307 self ._create_process_result_service ().start ()
308- self ._started_at = time .time ()
308+ self ._started_at = time .monotonic ()
309309
310310 if self ._progress is not None :
311311 self ._progress .update_max_value (len (data ))
@@ -314,12 +314,12 @@ def process(self, func, data, *args, **kwargs):
314314 with ThreadPoolExecutor (max_workers = self ._num_workers ,
315315 thread_name_prefix = "CPF_PROCESS_WORKER" ) as self ._executor :
316316 for item in data :
317- start_time = time .time ()
317+ start_time = time .monotonic ()
318318
319319 future = self ._executor .submit (self ._process , func , item , * args , ** kwargs )
320320 self ._future_to_data .add (future )
321321
322- elapsed_time = time .time () - start_time
322+ elapsed_time = time .monotonic () - start_time
323323 # Verifica quanto tempo passou após enviar um dado, caso o tempo for menor que o intervalo
324324 # configurado espera a diferença antes de enviar o próximo lote
325325 if elapsed_time < self .interval_seconds :
@@ -346,7 +346,7 @@ def stop_process(self):
346346 def restart_process (self ):
347347 self .stop_process () # espera terminar execução do processo anterior
348348 self ._stopped = False
349- self ._started_at = time .time ()
349+ self ._started_at = time .monotonic ()
350350 self ._failure_data = []
351351 self ._total_success = 0
352352 self ._create_process_result_service ().start ()
0 commit comments