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
This commit is contained in:
parent
baf07c4be2
commit
6b0946ee69
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue