From 6b0946ee69593e57d66f700c16f8f5af21e72dfa Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Sun, 24 Nov 2019 02:03:46 +0700 Subject: [PATCH] trx_toolkit/clck_gen.py: turn CLCKGen's thread into a daemon If the main thread crashes, the CLCKGen's thread would never stop. It would also happen if the main thread terminates without calling CLCKGen.stop(). Let's prevent this by creating a daemon thread. Change-Id: I9d41c5baa25fa0a263758414a164c1bded25e04e --- src/target/trx_toolkit/clck_gen.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/target/trx_toolkit/clck_gen.py b/src/target/trx_toolkit/clck_gen.py index 92ca217c5..a50c9858e 100755 --- a/src/target/trx_toolkit/clck_gen.py +++ b/src/target/trx_toolkit/clck_gen.py @@ -70,6 +70,7 @@ class CLCKGen: # Initialize and start a new thread self._thread = threading.Thread(target = self._worker) + self._thread.setDaemon(True) self._thread.start() def stop(self): @@ -128,6 +129,9 @@ class Application(ApplicationBase): self.clck = CLCKGen([self.link], ind_period = 51) self.clck.start() + # Block unless we receive a signal + self.clck._thread.join() + def sig_handler(self, signum, frame): log.info("Signal %d received" % signum) if signum == signal.SIGINT: