From 3506e26757d75353cb3ae39dada362039ea173a8 Mon Sep 17 00:00:00 2001 From: sean Date: Fri, 4 Oct 2024 12:56:02 +0100 Subject: [PATCH] possibly better --- helpers/cudo_api.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/helpers/cudo_api.py b/helpers/cudo_api.py index 6e7f59d..9572d56 100644 --- a/helpers/cudo_api.py +++ b/helpers/cudo_api.py @@ -150,7 +150,6 @@ def worker(self): print(f"Error creating VM: {e}") self.task_queue.task_done() - print("Task done") def start_queue(self): if not self.task_queue: @@ -165,16 +164,15 @@ def start_workers(self): self.executor.submit(self.worker) def stop_workers(self): - print("stop workers") - # if not self.shutdown_event.is_set(): - # try: - # self.workers_active = False - # self.shutdown_event.set() - # - # self.executor.shutdown(wait=False) - # - # except Exception as e: - # print(f"Error shutting down: {e}") + if not self.shutdown_event.is_set(): + try: + self.workers_active = False + self.shutdown_event.set() + + self.executor.shutdown(wait=False) + + except Exception as e: + print(f"Error shutting down: {e}")