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: