From a7961d74ba925183dd2902bf2b44b24fe90619b6 Mon Sep 17 00:00:00 2001 From: Alex Wiens <alex.wiens@uni-paderborn.de> Date: Mon, 17 Feb 2025 18:40:50 +0100 Subject: [PATCH] Prule.daemon: Add catching of all exceptions in a thread and shutting down. --- prule/daemon/__main__.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/prule/daemon/__main__.py b/prule/daemon/__main__.py index e7e91b4..75847ed 100644 --- a/prule/daemon/__main__.py +++ b/prule/daemon/__main__.py @@ -491,7 +491,7 @@ class CCCheckThread(threading.Thread): if smallest_starttime < sys.maxsize: queue.smallest_starttime = smallest_starttime - def run(self): + def run_main(self): self.executor = concurrent.futures.ThreadPoolExecutor(max_workers=1) while self.stopThread == False: @@ -514,6 +514,14 @@ class CCCheckThread(threading.Thread): # thread done print("CCCheckThread Done") self.executor.shutdown(wait=False) + def run(self): + try: + self.run_main() + except Exception as e: + traceback.print_exc() + print("CCCheckThread",e) + if self.config.shutdown == False: + self.config.signal_shutdown() def stop(self): with self.stopCondition: print("Stop CCCheckThread") @@ -884,7 +892,7 @@ class PruleThread(threading.Thread): job_tempdir.cleanup() return process_result - def run(self): + def run_main(self): if self.config.config["CACHE_DB"] == True: self.db_con = prule.db.ResultsDB(self.config.config["DB_PATH"]) @@ -1003,6 +1011,14 @@ class PruleThread(threading.Thread): if self.config.config["CACHE_DB"] == True: self.db_con.close() self.db_con = None + def run(self): + try: + self.run_main() + except Exception as e: + traceback.print_exc() + print("PruleThread:",e) + if self.config.shutdown == False: + self.config.signal_shutdown() def stop(self): with self.stopCondition: if self.currentProcess != None: -- GitLab