From 1aef0932b8e2a1eb8f747156ae1a4ff4b0755520 Mon Sep 17 00:00:00 2001 From: Ashish Agrahari Date: Thu, 18 Jul 2024 21:40:00 -0400 Subject: [PATCH 01/10] Added restart of workers --- documentation/main_multiprocess_example.py | 3 ++ main_2024.py | 8 ++++ utilities/workers/worker_manager.py | 54 ++++++++++++++++++++++ 3 files changed, 65 insertions(+) diff --git a/documentation/main_multiprocess_example.py b/documentation/main_multiprocess_example.py index 98fa1dc2..57cf0d50 100644 --- a/documentation/main_multiprocess_example.py +++ b/documentation/main_multiprocess_example.py @@ -88,6 +88,7 @@ def main() -> int: output_queues=[countup_to_add_random_queue], controller=controller, local_logger=main_logger, + worker_name="Countup", ) if not result: print("Failed to create arguments for Countup") @@ -108,6 +109,7 @@ def main() -> int: output_queues=[add_random_to_concatenator_queue], controller=controller, local_logger=main_logger, + worker_name="Add Random", ) if not result: print("Failed to create arguments for Add Random") @@ -127,6 +129,7 @@ def main() -> int: output_queues=[], controller=controller, local_logger=main_logger, + worker_name="Concatenator", ) if not result: print("Failed to create arguments for Concatenator") diff --git a/main_2024.py b/main_2024.py index b34c522a..4c3fa7f9 100644 --- a/main_2024.py +++ b/main_2024.py @@ -172,6 +172,7 @@ def main() -> int: output_queues=[video_input_to_detect_target_queue], controller=controller, local_logger=main_logger, + worker_name="Video Input", ) if not result: frame = inspect.currentframe() @@ -195,6 +196,7 @@ def main() -> int: output_queues=[detect_target_to_data_merge_queue], controller=controller, local_logger=main_logger, + worker_name="Detect Target", ) if not result: frame = inspect.currentframe() @@ -217,6 +219,7 @@ def main() -> int: output_queues=[flight_interface_to_data_merge_queue], controller=controller, local_logger=main_logger, + worker_name="Flight Interface", ) if not result: frame = inspect.currentframe() @@ -237,6 +240,7 @@ def main() -> int: output_queues=[data_merge_to_geolocation_queue], controller=controller, local_logger=main_logger, + worker_name="Data Merge", ) if not result: frame = inspect.currentframe() @@ -257,6 +261,7 @@ def main() -> int: output_queues=[geolocation_to_main_queue], controller=controller, local_logger=main_logger, + worker_name="Geolocation", ) if not result: frame = inspect.currentframe() @@ -344,6 +349,9 @@ def main() -> int: manager.start_workers() while True: + for manager in worker_managers: + manager.check_and_restart_dead_workers() + try: geolocation_data = geolocation_to_main_queue.queue.get_nowait() except queue.Empty: diff --git a/utilities/workers/worker_manager.py b/utilities/workers/worker_manager.py index 37d79282..b403d889 100644 --- a/utilities/workers/worker_manager.py +++ b/utilities/workers/worker_manager.py @@ -27,6 +27,7 @@ def create( output_queues: "list[queue_proxy_wrapper.QueueProxyWrapper]", controller: worker_controller.WorkerController, local_logger: logger.Logger, + worker_name: str, ) -> "tuple[bool, WorkerProperties | None]": """ Creates worker properties. @@ -38,6 +39,7 @@ def create( output_queues: Output queues. controller: Worker controller. local_logger: Existing logger from process. + worker_name: Name of the worker type. Returns the WorkerProperties object. """ @@ -57,6 +59,7 @@ def create( input_queues, output_queues, controller, + worker_name, ) def __init__( @@ -68,6 +71,7 @@ def __init__( input_queues: "list[queue_proxy_wrapper.QueueProxyWrapper]", output_queues: "list[queue_proxy_wrapper.QueueProxyWrapper]", controller: worker_controller.WorkerController, + worker_name: str, ) -> None: """ Private constructor, use create() method. @@ -80,6 +84,7 @@ def __init__( self.__input_queues = input_queues self.__output_queues = output_queues self.__controller = controller + self.__worker_name = worker_name def get_worker_arguments(self) -> "tuple": """ @@ -106,6 +111,18 @@ def get_worker_target(self) -> "(...) -> object": # type: ignore """ return self.__target + def get_input_queues(self) -> "list[queue_proxy_wrapper.QueueProxyWrapper]": + """ + Returns the input queues. + """ + return self.__input_queues + + def get_worker_name(self) -> str: + """ + Returns the name of the worker type. + """ + return self.__worker_name + class WorkerManager: """ @@ -146,12 +163,16 @@ def create( return True, WorkerManager( cls.__create_key, workers, + worker_properties, + local_logger, ) def __init__( self, class_private_create_key: object, workers: "list[mp.Process]", + worker_properties: WorkerProperties, + local_logger: logger.Logger, ) -> None: """ Private constructor, use create() method. @@ -159,6 +180,8 @@ def __init__( assert class_private_create_key is WorkerManager.__create_key, "Use create() method" self.__workers = workers + self.__worker_properties = worker_properties + self.__local_logger = local_logger @staticmethod def __create_single_worker(target: "(...) -> object", args: "tuple", local_logger: logger.Logger) -> "tuple[bool, mp.Process | None]": # type: ignore @@ -195,3 +218,34 @@ def join_workers(self) -> None: """ for worker in self.__workers: worker.join() + + def check_and_restart_dead_workers(self) -> None: + """ + Check and restart dead workers. + """ + for worker in self.__workers: + if not worker.is_alive(): + # Log the error + frame = inspect.currentframe() + worker_name_string = self.__worker_properties.get_worker_name() + " worker" + self.__local_logger.error("Worker died, restarting " + worker_name_string, frame) + + # Terminate and join worker + worker.terminate() + worker.join() + + # Drain the preceding queues + input_queues = self.__worker_properties.get_input_queues() + for queue in input_queues: + queue.drain_queue() + + # Create a new worker + result, worker = WorkerManager.__create_single_worker( + self.__worker_properties.get_worker_target(), + self.__worker_properties.get_worker_arguments(), + self.__local_logger, + ) + if not result: + frame = inspect.currentframe() + self.__local_logger.error("Failed to restart " + worker_name_string, frame) + return False, None From f101414c77e7dad059277125323d31f95bb3c360 Mon Sep 17 00:00:00 2001 From: Ashish Agrahari Date: Fri, 19 Jul 2024 21:28:41 -0400 Subject: [PATCH 02/10] Added del worker --- utilities/workers/worker_manager.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/utilities/workers/worker_manager.py b/utilities/workers/worker_manager.py index b403d889..8b642cef 100644 --- a/utilities/workers/worker_manager.py +++ b/utilities/workers/worker_manager.py @@ -233,6 +233,8 @@ def check_and_restart_dead_workers(self) -> None: # Terminate and join worker worker.terminate() worker.join() + del worker + worker = None # Drain the preceding queues input_queues = self.__worker_properties.get_input_queues() From b03da997469a715fdceae30f7e094b8fb668384e Mon Sep 17 00:00:00 2001 From: Ashish Agrahari Date: Fri, 19 Jul 2024 21:36:44 -0400 Subject: [PATCH 03/10] Fix return statement --- utilities/workers/worker_manager.py | 1 - 1 file changed, 1 deletion(-) diff --git a/utilities/workers/worker_manager.py b/utilities/workers/worker_manager.py index 8b642cef..692a102c 100644 --- a/utilities/workers/worker_manager.py +++ b/utilities/workers/worker_manager.py @@ -250,4 +250,3 @@ def check_and_restart_dead_workers(self) -> None: if not result: frame = inspect.currentframe() self.__local_logger.error("Failed to restart " + worker_name_string, frame) - return False, None From d53e7207a1529db87207c44d14505ac93593c13a Mon Sep 17 00:00:00 2001 From: Ashish Agrahari Date: Wed, 24 Jul 2024 21:36:25 -0400 Subject: [PATCH 04/10] Moved draining queues --- utilities/workers/worker_manager.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/utilities/workers/worker_manager.py b/utilities/workers/worker_manager.py index 692a102c..3d795303 100644 --- a/utilities/workers/worker_manager.py +++ b/utilities/workers/worker_manager.py @@ -236,11 +236,6 @@ def check_and_restart_dead_workers(self) -> None: del worker worker = None - # Drain the preceding queues - input_queues = self.__worker_properties.get_input_queues() - for queue in input_queues: - queue.drain_queue() - # Create a new worker result, worker = WorkerManager.__create_single_worker( self.__worker_properties.get_worker_target(), @@ -250,3 +245,8 @@ def check_and_restart_dead_workers(self) -> None: if not result: frame = inspect.currentframe() self.__local_logger.error("Failed to restart " + worker_name_string, frame) + + # Drain the preceding queues + input_queues = self.__worker_properties.get_input_queues() + for queue in input_queues: + queue.drain_queue() From 7678127e8ed935de1e138bc09de8f9c1efe89d9d Mon Sep 17 00:00:00 2001 From: Ashish Agrahari Date: Sat, 27 Jul 2024 11:21:47 -0400 Subject: [PATCH 05/10] Fixing restart --- log.txt | 3 + main_2024.py | 6 +- utilities/workers/worker_manager.py | 88 ++++++++++++++++++++++------- 3 files changed, 76 insertions(+), 21 deletions(-) create mode 100644 log.txt diff --git a/log.txt b/log.txt new file mode 100644 index 00000000..883d9e41 --- /dev/null +++ b/log.txt @@ -0,0 +1,3 @@ +[WinError 10061] No connection could be made because the target machine actively refused it sleeping +[WinError 10061] No connection could be made because the target machine actively refused it sleeping +Cannot connect to drone! Make sure the address/port is correct. diff --git a/main_2024.py b/main_2024.py index 4c3fa7f9..85f7942c 100644 --- a/main_2024.py +++ b/main_2024.py @@ -350,7 +350,11 @@ def main() -> int: while True: for manager in worker_managers: - manager.check_and_restart_dead_workers() + result = manager.check_and_restart_dead_workers() + if not result: + frame = inspect.currentframe() + main_logger.error("Failed to restart workers", frame) + return -1 try: geolocation_data = geolocation_to_main_queue.queue.get_nowait() diff --git a/utilities/workers/worker_manager.py b/utilities/workers/worker_manager.py index 3d795303..aac5d092 100644 --- a/utilities/workers/worker_manager.py +++ b/utilities/workers/worker_manager.py @@ -219,34 +219,82 @@ def join_workers(self) -> None: for worker in self.__workers: worker.join() - def check_and_restart_dead_workers(self) -> None: + def check_and_restart_dead_workers(self) -> bool: """ Check and restart dead workers. + + Returns whether the dead workers were able to be restarted. """ + new_workers = [] for worker in self.__workers: - if not worker.is_alive(): - # Log the error - frame = inspect.currentframe() - worker_name_string = self.__worker_properties.get_worker_name() + " worker" - self.__local_logger.error("Worker died, restarting " + worker_name_string, frame) - - # Terminate and join worker + if worker.is_alive(): + new_workers.append(worker) + else: worker.terminate() worker.join() - del worker - worker = None - - # Create a new worker - result, worker = WorkerManager.__create_single_worker( - self.__worker_properties.get_worker_target(), - self.__worker_properties.get_worker_arguments(), - self.__local_logger, - ) - if not result: - frame = inspect.currentframe() - self.__local_logger.error("Failed to restart " + worker_name_string, frame) + + del self.__workers + self.__workers = new_workers + + while len(self.__workers) < self.__worker_properties.get_worker_count(): + # Log the error + frame = inspect.currentframe() + worker_name_string = self.__worker_properties.get_worker_name() + " worker" + self.__local_logger.error("Worker died, restarting " + worker_name_string, frame) + + # Create a new worker + result, new_worker = WorkerManager.__create_single_worker( + self.__worker_properties.get_worker_target(), + self.__worker_properties.get_worker_arguments(), + self.__local_logger, + ) + if not result: + frame = inspect.currentframe() + self.__local_logger.error("Failed to restart " + worker_name_string, frame) + return False + + # Append the new worker + new_workers.append(new_worker) + + # for worker in self.__workers: + # if not worker.is_alive(): + # # Log the error + # frame = inspect.currentframe() + # worker_name_string = self.__worker_properties.get_worker_name() + " worker" + # self.__local_logger.error("Worker died, restarting " + worker_name_string, frame) + + # del worker + # worker = None + + # # Create a new worker + # result, new_worker = WorkerManager.__create_single_worker( + # self.__worker_properties.get_worker_target(), + # self.__worker_properties.get_worker_arguments(), + # self.__local_logger, + # ) + # if not result: + # frame = inspect.currentframe() + # self.__local_logger.error("Failed to restart " + worker_name_string, frame) + # return False + + # # Append the new worker + # new_workers.append(new_worker) + + # else: + # new_workers.append(worker) + + # Delete the old workers list and set it to the new list + # for worker in self.__workers: + # # Terminate and join worker + # worker.terminate() + # worker.join() + + # del self.__workers + # self.__workers = new_workers # Drain the preceding queues input_queues = self.__worker_properties.get_input_queues() for queue in input_queues: queue.drain_queue() + + return True From 0796d26601250e4290e588d58199f25ac2fadd8f Mon Sep 17 00:00:00 2001 From: Ashish Agrahari Date: Tue, 6 Aug 2024 18:42:50 -0400 Subject: [PATCH 06/10] Fixed nonetype error --- utilities/workers/worker_manager.py | 41 +---------------------------- 1 file changed, 1 insertion(+), 40 deletions(-) diff --git a/utilities/workers/worker_manager.py b/utilities/workers/worker_manager.py index aac5d092..ca568149 100644 --- a/utilities/workers/worker_manager.py +++ b/utilities/workers/worker_manager.py @@ -229,9 +229,6 @@ def check_and_restart_dead_workers(self) -> bool: for worker in self.__workers: if worker.is_alive(): new_workers.append(worker) - else: - worker.terminate() - worker.join() del self.__workers self.__workers = new_workers @@ -254,43 +251,7 @@ def check_and_restart_dead_workers(self) -> bool: return False # Append the new worker - new_workers.append(new_worker) - - # for worker in self.__workers: - # if not worker.is_alive(): - # # Log the error - # frame = inspect.currentframe() - # worker_name_string = self.__worker_properties.get_worker_name() + " worker" - # self.__local_logger.error("Worker died, restarting " + worker_name_string, frame) - - # del worker - # worker = None - - # # Create a new worker - # result, new_worker = WorkerManager.__create_single_worker( - # self.__worker_properties.get_worker_target(), - # self.__worker_properties.get_worker_arguments(), - # self.__local_logger, - # ) - # if not result: - # frame = inspect.currentframe() - # self.__local_logger.error("Failed to restart " + worker_name_string, frame) - # return False - - # # Append the new worker - # new_workers.append(new_worker) - - # else: - # new_workers.append(worker) - - # Delete the old workers list and set it to the new list - # for worker in self.__workers: - # # Terminate and join worker - # worker.terminate() - # worker.join() - - # del self.__workers - # self.__workers = new_workers + self.__workers.append(new_worker) # Drain the preceding queues input_queues = self.__worker_properties.get_input_queues() From 05901b94b1b6718d41ff293767ca34b59dcf9a1d Mon Sep 17 00:00:00 2001 From: Ashish Agrahari Date: Sat, 10 Aug 2024 21:58:15 -0400 Subject: [PATCH 07/10] Update PR --- documentation/main_multiprocess_example.py | 3 -- log.txt | 3 -- main_2024.py | 5 -- modules/common | 2 +- utilities/workers/worker_manager.py | 60 +++++++++++----------- 5 files changed, 31 insertions(+), 42 deletions(-) delete mode 100644 log.txt diff --git a/documentation/main_multiprocess_example.py b/documentation/main_multiprocess_example.py index 57cf0d50..98fa1dc2 100644 --- a/documentation/main_multiprocess_example.py +++ b/documentation/main_multiprocess_example.py @@ -88,7 +88,6 @@ def main() -> int: output_queues=[countup_to_add_random_queue], controller=controller, local_logger=main_logger, - worker_name="Countup", ) if not result: print("Failed to create arguments for Countup") @@ -109,7 +108,6 @@ def main() -> int: output_queues=[add_random_to_concatenator_queue], controller=controller, local_logger=main_logger, - worker_name="Add Random", ) if not result: print("Failed to create arguments for Add Random") @@ -129,7 +127,6 @@ def main() -> int: output_queues=[], controller=controller, local_logger=main_logger, - worker_name="Concatenator", ) if not result: print("Failed to create arguments for Concatenator") diff --git a/log.txt b/log.txt deleted file mode 100644 index 883d9e41..00000000 --- a/log.txt +++ /dev/null @@ -1,3 +0,0 @@ -[WinError 10061] No connection could be made because the target machine actively refused it sleeping -[WinError 10061] No connection could be made because the target machine actively refused it sleeping -Cannot connect to drone! Make sure the address/port is correct. diff --git a/main_2024.py b/main_2024.py index 85f7942c..d68adaa0 100644 --- a/main_2024.py +++ b/main_2024.py @@ -172,7 +172,6 @@ def main() -> int: output_queues=[video_input_to_detect_target_queue], controller=controller, local_logger=main_logger, - worker_name="Video Input", ) if not result: frame = inspect.currentframe() @@ -196,7 +195,6 @@ def main() -> int: output_queues=[detect_target_to_data_merge_queue], controller=controller, local_logger=main_logger, - worker_name="Detect Target", ) if not result: frame = inspect.currentframe() @@ -219,7 +217,6 @@ def main() -> int: output_queues=[flight_interface_to_data_merge_queue], controller=controller, local_logger=main_logger, - worker_name="Flight Interface", ) if not result: frame = inspect.currentframe() @@ -240,7 +237,6 @@ def main() -> int: output_queues=[data_merge_to_geolocation_queue], controller=controller, local_logger=main_logger, - worker_name="Data Merge", ) if not result: frame = inspect.currentframe() @@ -261,7 +257,6 @@ def main() -> int: output_queues=[geolocation_to_main_queue], controller=controller, local_logger=main_logger, - worker_name="Geolocation", ) if not result: frame = inspect.currentframe() diff --git a/modules/common b/modules/common index cc6384ec..b55dfd3b 160000 --- a/modules/common +++ b/modules/common @@ -1 +1 @@ -Subproject commit cc6384ecbcf1ff02edc610dcc5accf0d732c1c66 +Subproject commit b55dfd3b26309f78d1fb0012060fa49ffc736f8d diff --git a/utilities/workers/worker_manager.py b/utilities/workers/worker_manager.py index ca568149..43ad648a 100644 --- a/utilities/workers/worker_manager.py +++ b/utilities/workers/worker_manager.py @@ -27,7 +27,6 @@ def create( output_queues: "list[queue_proxy_wrapper.QueueProxyWrapper]", controller: worker_controller.WorkerController, local_logger: logger.Logger, - worker_name: str, ) -> "tuple[bool, WorkerProperties | None]": """ Creates worker properties. @@ -39,7 +38,6 @@ def create( output_queues: Output queues. controller: Worker controller. local_logger: Existing logger from process. - worker_name: Name of the worker type. Returns the WorkerProperties object. """ @@ -59,7 +57,6 @@ def create( input_queues, output_queues, controller, - worker_name, ) def __init__( @@ -71,7 +68,6 @@ def __init__( input_queues: "list[queue_proxy_wrapper.QueueProxyWrapper]", output_queues: "list[queue_proxy_wrapper.QueueProxyWrapper]", controller: worker_controller.WorkerController, - worker_name: str, ) -> None: """ Private constructor, use create() method. @@ -84,7 +80,6 @@ def __init__( self.__input_queues = input_queues self.__output_queues = output_queues self.__controller = controller - self.__worker_name = worker_name def get_worker_arguments(self) -> "tuple": """ @@ -117,11 +112,11 @@ def get_input_queues(self) -> "list[queue_proxy_wrapper.QueueProxyWrapper]": """ return self.__input_queues - def get_worker_name(self) -> str: + def get_target_name(self) -> str: """ - Returns the name of the worker type. + Returns the name of the target. """ - return self.__worker_name + return self.__target.__name__ class WorkerManager: @@ -229,31 +224,36 @@ def check_and_restart_dead_workers(self) -> bool: for worker in self.__workers: if worker.is_alive(): new_workers.append(worker) - - del self.__workers - self.__workers = new_workers - - while len(self.__workers) < self.__worker_properties.get_worker_count(): - # Log the error - frame = inspect.currentframe() - worker_name_string = self.__worker_properties.get_worker_name() + " worker" - self.__local_logger.error("Worker died, restarting " + worker_name_string, frame) - - # Create a new worker - result, new_worker = WorkerManager.__create_single_worker( - self.__worker_properties.get_worker_target(), - self.__worker_properties.get_worker_arguments(), - self.__local_logger, - ) - if not result: + else: + # Log the error frame = inspect.currentframe() - self.__local_logger.error("Failed to restart " + worker_name_string, frame) - return False + target_and_worker_name = ( + self.__worker_properties.get_target_name() + " " + worker.name + ) + self.__local_logger.error( + "Worker died, restarting " + target_and_worker_name, + frame, + ) + + # Create a new worker + result, new_worker = WorkerManager.__create_single_worker( + self.__worker_properties.get_worker_target(), + self.__worker_properties.get_worker_arguments(), + self.__local_logger, + ) + if not result: + frame = inspect.currentframe() + self.__local_logger.error("Failed to restart " + target_and_worker_name, frame) + return False + + # Append the new worker + new_workers.append(new_worker) - # Append the new worker - self.__workers.append(new_worker) + self.__workers = new_workers - # Drain the preceding queues + # Draining the preceding queue ensures that the preceding queue data wasn't what + # caused the worker to fail. Draining the succeeding queues is not needed + # because a worker that died would not have put bad data into the queue. input_queues = self.__worker_properties.get_input_queues() for queue in input_queues: queue.drain_queue() From ab188f19900211e8f4510dd9288d271069ffed8f Mon Sep 17 00:00:00 2001 From: Ashish Agrahari Date: Sat, 10 Aug 2024 22:12:43 -0400 Subject: [PATCH 08/10] Removed else --- utilities/workers/worker_manager.py | 47 +++++++++++++++-------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/utilities/workers/worker_manager.py b/utilities/workers/worker_manager.py index 43ad648a..65688f65 100644 --- a/utilities/workers/worker_manager.py +++ b/utilities/workers/worker_manager.py @@ -224,30 +224,31 @@ def check_and_restart_dead_workers(self) -> bool: for worker in self.__workers: if worker.is_alive(): new_workers.append(worker) - else: - # Log the error + continue + + # Log the error + frame = inspect.currentframe() + target_and_worker_name = ( + self.__worker_properties.get_target_name() + " " + worker.name + ) + self.__local_logger.warning( + "Worker died, restarting " + target_and_worker_name, + frame, + ) + + # Create a new worker + result, new_worker = WorkerManager.__create_single_worker( + self.__worker_properties.get_worker_target(), + self.__worker_properties.get_worker_arguments(), + self.__local_logger, + ) + if not result: frame = inspect.currentframe() - target_and_worker_name = ( - self.__worker_properties.get_target_name() + " " + worker.name - ) - self.__local_logger.error( - "Worker died, restarting " + target_and_worker_name, - frame, - ) - - # Create a new worker - result, new_worker = WorkerManager.__create_single_worker( - self.__worker_properties.get_worker_target(), - self.__worker_properties.get_worker_arguments(), - self.__local_logger, - ) - if not result: - frame = inspect.currentframe() - self.__local_logger.error("Failed to restart " + target_and_worker_name, frame) - return False - - # Append the new worker - new_workers.append(new_worker) + self.__local_logger.error("Failed to restart " + target_and_worker_name, frame) + return False + + # Append the new worker + new_workers.append(new_worker) self.__workers = new_workers From 9694b6da80cfe8bf5eacb6dd1e8708f269ab345e Mon Sep 17 00:00:00 2001 From: Ashish Agrahari Date: Sat, 10 Aug 2024 22:15:37 -0400 Subject: [PATCH 09/10] Fixed formatting --- utilities/workers/worker_manager.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/utilities/workers/worker_manager.py b/utilities/workers/worker_manager.py index 65688f65..48631822 100644 --- a/utilities/workers/worker_manager.py +++ b/utilities/workers/worker_manager.py @@ -228,9 +228,7 @@ def check_and_restart_dead_workers(self) -> bool: # Log the error frame = inspect.currentframe() - target_and_worker_name = ( - self.__worker_properties.get_target_name() + " " + worker.name - ) + target_and_worker_name = self.__worker_properties.get_target_name() + " " + worker.name self.__local_logger.warning( "Worker died, restarting " + target_and_worker_name, frame, From 52e758ffd60c88c19e2403ff4c930c161597df0b Mon Sep 17 00:00:00 2001 From: Ashish Agrahari Date: Sat, 10 Aug 2024 22:22:43 -0400 Subject: [PATCH 10/10] Made f strings --- utilities/workers/worker_manager.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/utilities/workers/worker_manager.py b/utilities/workers/worker_manager.py index 48631822..c4edf505 100644 --- a/utilities/workers/worker_manager.py +++ b/utilities/workers/worker_manager.py @@ -226,11 +226,11 @@ def check_and_restart_dead_workers(self) -> bool: new_workers.append(worker) continue - # Log the error + # Log dead worker frame = inspect.currentframe() - target_and_worker_name = self.__worker_properties.get_target_name() + " " + worker.name + target_and_worker_name = f"{self.__worker_properties.get_target_name()} {worker.name}" self.__local_logger.warning( - "Worker died, restarting " + target_and_worker_name, + f"Worker died, restarting {target_and_worker_name}", frame, ) @@ -242,7 +242,7 @@ def check_and_restart_dead_workers(self) -> bool: ) if not result: frame = inspect.currentframe() - self.__local_logger.error("Failed to restart " + target_and_worker_name, frame) + self.__local_logger.error(f"Failed to restart {target_and_worker_name}", frame) return False # Append the new worker