Reduce call thread-context api, after scan done

This commit is contained in:
localhost_frssoft 2022-10-12 19:45:05 +03:00
parent de6c3eb8fa
commit e4a5534edd

View File

@ -37,6 +37,7 @@ def scan_context_thread():
poll_created = get_state('poll_status_id')
stop_thread_scan = get_state('stop_thread_scan')
time_now = int(time.time())
reserve_time = False
while status_id is None or stop_thread_scan is None:
fail_limit = Counter()
status_id = get_state('last_thread_id')
@ -44,6 +45,7 @@ def scan_context_thread():
time.sleep(1)
if time_now >= int(stop_thread_scan):
reserve_time = True
logger.debug('Сбор завершён, сканирование треда на опоздавших')
if poll_created is None:
create_poll_movies()
@ -54,6 +56,8 @@ def scan_context_thread():
else:
endings = int(stop_thread_scan) - time_now
logger.debug(f'Осталось до закрытия сбора: {endings}')
if reserve_time: # Reduce instance load
time.sleep(30)
descendants = get_status_context(status_id)['descendants']
replyed = []
for status in descendants: