From 1cdce610856b7f086943b18ca53374b9d0a9d699 Mon Sep 17 00:00:00 2001 From: alya Date: Wed, 20 Dec 2023 15:30:55 +0200 Subject: [PATCH] output.py: better handling of the termination of PBar --- slips_files/core/helpers/progress_bar.py | 4 +++- slips_files/core/output.py | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/slips_files/core/helpers/progress_bar.py b/slips_files/core/helpers/progress_bar.py index 5be3e64a7..1160d8705 100644 --- a/slips_files/core/helpers/progress_bar.py +++ b/slips_files/core/helpers/progress_bar.py @@ -159,8 +159,8 @@ def pbar_supported(self) -> bool: return True def run(self): + """keeps receiving events until pbar reaches 100%""" try: - """keeps receiving events until pbar reaches 100%""" while self.pbar_supported(): try: msg: dict = self.pipe.recv() @@ -182,10 +182,12 @@ def run(self): if event == "terminate": self.terminate() + return if event == "print": # let tqdm do th eprinting to avoid conflicts with the pbar self.print(msg) + except Exception as e: tqdm.write(f"PBar Error: {e}") diff --git a/slips_files/core/output.py b/slips_files/core/output.py index 7862b2483..3500ae92a 100644 --- a/slips_files/core/output.py +++ b/slips_files/core/output.py @@ -289,6 +289,8 @@ def shutdown_gracefully(self): self.manager.shutdown() self.send_pipe.close() self.recv_pipe.close() + if hasattr(self, 'pbar'): + self.pbar.join(3) def tell_pbar(self, msg: dict): @@ -309,7 +311,8 @@ def update(self, msg: dict): wanna log the text to all logfiles or the cli only? txt: text to log to the logfiles and/or the cli bar_info: { - input_type: only given when we send bar:'init', specifies the type of the input file given to slips + input_type: only given when we send bar:'init', + specifies the type of the input file given to slips eg zeek, argus, etc total_flows: int, }