diff --git a/core.py b/core.py index 704d742..69059a3 100644 --- a/core.py +++ b/core.py @@ -100,7 +100,7 @@ def main(): # Otherwise, forward the update to the corresponding worker receiving_worker = chat_workers.get(update.message.chat.id) # Ensure a worker exists for the chat and is alive - if receiving_worker is None or not receiving_worker.is_alive(): + if receiving_worker is None or not receiving_worker.is_ready(): log.debug(f"Received a message in a chat without worker: {update.message.chat.id}") # Suggest that the user restarts the chat with /start bot.send_message(update.message.chat.id, default_loc.get("error_no_worker_for_chat"), diff --git a/worker.py b/worker.py index ca6128b..0dc9a63 100644 --- a/worker.py +++ b/worker.py @@ -130,6 +130,10 @@ class Worker(threading.Thread): self.sentry_client.captureException() traceback.print_exception(*sys.exc_info()) + def is_ready(self): + # Change this if more parameters are added! + return self.loc is not None + def stop(self, reason: str = ""): """Gracefully stop the worker process""" # Send a stop message to the thread