diff --git a/get_data.py b/get_data.py index 8c061fa..becb136 100644 --- a/get_data.py +++ b/get_data.py @@ -330,8 +330,15 @@ async def lifespan(app: FastAPI): GAME_TODAY = is_today # 4. запускаем "длинные" потоки (они у тебя и так всегда) - threads_long = [ - threading.Thread( + thread_result_consumer = threading.Thread( + target=results_consumer, + daemon=True, + ) + thread_result_consumer.start() + + # 5. Подготовим онлайн и офлайн наборы (как у тебя) + threads_live = [ + threading.Thread( target=get_data_from_API, args=( "pregame", @@ -367,22 +374,13 @@ async def lifespan(app: FastAPI): ), daemon=True, ), - threading.Thread( - target=results_consumer, - daemon=True, - ), - ] - for t in threads_long: - t.start() - # 5. Подготовим онлайн и офлайн наборы (как у тебя) - threads_live = [ threading.Thread( target=get_data_from_API, args=( "game", URLS["game"].format(host=HOST, game_id=game_id, lang=LANG), - 3, + 0.00016, stop_event, ), daemon=True, @@ -487,8 +485,7 @@ async def lifespan(app: FastAPI): # -------- shutdown -------- stop_event.set() - for t in threads_long: - t.join(timeout=1) + thread_result_consumer.join(timeout=1) # офлайн/онлайн ты можешь не делить тут, но оставлю for t in threads_offline: t.join(timeout=1)