From bd1f8005ea98872eb5725dcca72e9a525532d269 Mon Sep 17 00:00:00 2001 From: snubba Date: Thu, 31 Oct 2024 15:25:28 +0100 Subject: [PATCH] adding the possibility to check if the tick thread is gone (#187) * adding the possibility to check if the tick thread is gone * use join to wait for thread --- pysyncobj/syncobj.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pysyncobj/syncobj.py b/pysyncobj/syncobj.py index ce93ae0..2a43c7a 100644 --- a/pysyncobj/syncobj.py +++ b/pysyncobj/syncobj.py @@ -291,6 +291,21 @@ 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() + self.__thread.join() + def waitReady(self): """ Waits until the transport is ready for operation.