fix init check
This commit is contained in:
parent
c8fa3e85e9
commit
11724ba1ca
@ -21,6 +21,7 @@ class Command(BaseCommand):
|
|||||||
sentry_sdk.capture_exception(ctx.error)
|
sentry_sdk.capture_exception(ctx.error)
|
||||||
logging.exception('Exception while processing update', exc_info=ctx.error)
|
logging.exception('Exception while processing update', exc_info=ctx.error)
|
||||||
|
|
||||||
|
initialized = False
|
||||||
dispatchers = []
|
dispatchers = []
|
||||||
|
|
||||||
def check_updates(dispatcher):
|
def check_updates(dispatcher):
|
||||||
@ -39,7 +40,7 @@ class Command(BaseCommand):
|
|||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
if not dispatchers or cache.get('bots_reset'):
|
if not initialized or cache.get('bots_reset'):
|
||||||
logging.warning('Reloading dispatchers')
|
logging.warning('Reloading dispatchers')
|
||||||
dispatchers = []
|
dispatchers = []
|
||||||
for bot in TelegramBot.objects.filter(active=True):
|
for bot in TelegramBot.objects.filter(active=True):
|
||||||
@ -50,6 +51,7 @@ class Command(BaseCommand):
|
|||||||
except TelegramError:
|
except TelegramError:
|
||||||
pass
|
pass
|
||||||
cache.delete('bots_reset')
|
cache.delete('bots_reset')
|
||||||
|
initialized = True
|
||||||
|
|
||||||
with ThreadPoolExecutor() as executor:
|
with ThreadPoolExecutor() as executor:
|
||||||
for dispatcher in dispatchers:
|
for dispatcher in dispatchers:
|
||||||
|
Loading…
Reference in New Issue
Block a user