From b3132e31cb116a7057a32f42bc5e017e3b98dd61 Mon Sep 17 00:00:00 2001 From: Philipp Date: Sat, 18 Feb 2017 20:35:02 +0100 Subject: [PATCH] changed thread running condition to .isAlive() --- mqtt-to-flipdot.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/mqtt-to-flipdot.py b/mqtt-to-flipdot.py index 34b7c67..370f644 100644 --- a/mqtt-to-flipdot.py +++ b/mqtt-to-flipdot.py @@ -41,17 +41,24 @@ def on_message(client, userdata, msg): text = payload #flipdot.send_marquee(text, speed) - if flipthread is not None: + if flipthread is not None and flipthread.isAlive(): flipdot.stopAnimation() + while flipthread.isAlive(): + flipdot.stopAnimation() #try to stop animation + time.sleep(0.1) flipthread.join() #wait for thread to finish + flipthread=Thread(target=flipdot.send_marquee, args=(text,speed)) flipthread.start() if msg.topic == "raum2/flipdot/text/set": payload = msg.payload.decode("utf-8") - if flipthread is not None: + if flipthread is not None and flipthread.isAlive(): flipdot.stopAnimation() + while flipthread.isAlive(): + flipdot.stopAnimation() #try to stop animation + time.sleep(0.1) flipthread.join() if len(payload)>0 and payload[0]=='~':