1
Fork 0
mirror of https://github.com/Steffo99/greed.git synced 2024-11-21 21:44:19 +00:00
This commit is contained in:
Steffo 2020-07-06 23:54:13 +02:00
parent faaeb08773
commit bd1b98437d
Signed by: steffo
GPG key ID: 896A80F55F7C97F0
2 changed files with 5 additions and 1 deletions

View file

@ -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"),

View file

@ -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