From fd02c8052ca283c2d06b65a04b5a3fd30713947a Mon Sep 17 00:00:00 2001 From: Marcel Hanke Date: Thu, 31 Oct 2024 13:34:21 +0100 Subject: [PATCH 1/2] adding the possibility to check if the tick thread is gone --- pysyncobj/syncobj.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pysyncobj/syncobj.py b/pysyncobj/syncobj.py index ce93ae0..9309551 100644 --- a/pysyncobj/syncobj.py +++ b/pysyncobj/syncobj.py @@ -291,6 +291,24 @@ def destroy(self): else: self._doDestroy() + def tick_thread_alive(self): + """ + Check if the tick thread is alive. + """ + if self.__thread and self.__thread.is_alive(): + return True + return False + + def destroy_synchronous(self): + """ + Correctly destroy SyncObj. Stop autoTickThread, close connections, etc. and ensure the threads are gone. + """ + self.destroy() + count = 0 + while self.tick_thread_alive(): + time.sleep(.1) + count += 1 + def waitReady(self): """ Waits until the transport is ready for operation. From b601f222fdf14a919374016b24d2f3fcce00033f Mon Sep 17 00:00:00 2001 From: Marcel Hanke Date: Thu, 31 Oct 2024 13:48:18 +0100 Subject: [PATCH 2/2] use join to wait for thread --- pysyncobj/syncobj.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pysyncobj/syncobj.py b/pysyncobj/syncobj.py index 9309551..2a43c7a 100644 --- a/pysyncobj/syncobj.py +++ b/pysyncobj/syncobj.py @@ -304,10 +304,7 @@ def destroy_synchronous(self): Correctly destroy SyncObj. Stop autoTickThread, close connections, etc. and ensure the threads are gone. """ self.destroy() - count = 0 - while self.tick_thread_alive(): - time.sleep(.1) - count += 1 + self.__thread.join() def waitReady(self): """