From 11724ba1ca0c1993178e004c028d3b31ba895df6 Mon Sep 17 00:00:00 2001 From: bakatrouble Date: Fri, 12 Mar 2021 00:48:40 +0300 Subject: [PATCH] fix init check --- bots/management/commands/bot_worker.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bots/management/commands/bot_worker.py b/bots/management/commands/bot_worker.py index afdd7e5..2a5eadb 100644 --- a/bots/management/commands/bot_worker.py +++ b/bots/management/commands/bot_worker.py @@ -21,6 +21,7 @@ class Command(BaseCommand): sentry_sdk.capture_exception(ctx.error) logging.exception('Exception while processing update', exc_info=ctx.error) + initialized = False dispatchers = [] def check_updates(dispatcher): @@ -39,7 +40,7 @@ class Command(BaseCommand): while True: try: - if not dispatchers or cache.get('bots_reset'): + if not initialized or cache.get('bots_reset'): logging.warning('Reloading dispatchers') dispatchers = [] for bot in TelegramBot.objects.filter(active=True): @@ -50,6 +51,7 @@ class Command(BaseCommand): except TelegramError: pass cache.delete('bots_reset') + initialized = True with ThreadPoolExecutor() as executor: for dispatcher in dispatchers: