summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2019-11-24 02:03:46 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2019-11-24 02:24:42 +0700
commit6b0946ee69593e57d66f700c16f8f5af21e72dfa (patch)
treefa78f7d092611f506bf45d8acaa5f4503d0e963f
parentbaf07c4be2faf791b4c5d34d065eafea1408e95a (diff)
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
-rwxr-xr-xsrc/target/trx_toolkit/clck_gen.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/target/trx_toolkit/clck_gen.py b/src/target/trx_toolkit/clck_gen.py
index 92ca217c..a50c9858 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: