From 575ca37033e779ce2b954b4444f6b124df8f4b3e Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 13 Apr 2018 09:40:31 +0200 Subject: [PATCH] #3: Do not crash if a CancelSignal is sent to a non-cancellable wait --- worker.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/worker.py b/worker.py index 615b446..ec7bfe7 100644 --- a/worker.py +++ b/worker.py @@ -125,9 +125,13 @@ class ChatWorker(threading.Thread): # Get the next update update = self.__receive_next_update() # Ensure the update isn't a CancelSignal - if cancellable and isinstance(update, CancelSignal): - # Return the CancelSignal - return update + if isinstance(update, CancelSignal): + if cancellable: + # Return the CancelSignal + return update + else: + # Ignore the signal + continue # Ensure the update contains a message if update.message is None: continue