fix init check

This commit is contained in:
bakatrouble 2021-03-12 00:48:40 +03:00
parent c8fa3e85e9
commit 11724ba1ca

View File

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