From 225e26a1bb6474407babae147e14dca174773d2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=AE=D1=80=D0=B8=D0=B9=20=D0=A7=D0=B5=D1=80=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=BA=D0=BE?= Date: Mon, 10 Nov 2025 10:45:05 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BF=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=BE=D1=84=D1=84=D0=BB=D0=B0=D0=B9=D0=BD=20=D1=82?= =?UTF-8?q?=D1=80=D0=B5=D0=B4.=20=D1=82=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20?= =?UTF-8?q?=D0=BF=D0=BE=D1=81=D0=BB=D0=B5=20=D0=BF=D0=B5=D1=80=D0=B2=D0=BE?= =?UTF-8?q?=D0=B3=D0=BE=20=D1=83=D1=81=D0=BF=D0=B5=D1=88=D0=BD=D0=BE=D0=B3?= =?UTF-8?q?=D0=BE=20=D0=BF=D0=BE=D0=BB=D1=83=D1=87=D0=B5=D0=BD=D0=B8=D1=8F?= =?UTF-8?q?=20game,=20=D0=BE=D1=82=D0=BA=D0=BB=D1=8E=D1=87=D0=B0=D0=B5?= =?UTF-8?q?=D1=82=20=D1=82=D1=80=D0=B5=D0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- get_data.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/get_data.py b/get_data.py index f1322b0..62f0b09 100644 --- a/get_data.py +++ b/get_data.py @@ -160,6 +160,8 @@ def start_offline_threads(season, game_id): URLS["game"].format(host=HOST, game_id=game_id, lang=LANG), 300, # опрашиваем раз в секунду/реже stop_event_offline, + False, + True, ), daemon=True, ), @@ -331,6 +333,7 @@ def get_data_from_API( sleep_time: float, stop_event: threading.Event, stop_when_live=False, + stop_after_success: bool = False, # 👈 новый флаг ): did_first_fetch = False while not stop_event.is_set(): @@ -370,6 +373,14 @@ def get_data_from_API( ts = datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")[:-3] results_q.put({"source": name, "ts": ts, "data": value}) logger.debug(f"[{ts}] name: {name}, status: {value.get('status', 'no-status')}") + ok_status = not ( + isinstance(value, dict) + and str(value.get("status", "")).lower() in ("error", "fail", "no-status") + ) + + if stop_after_success and ok_status: + logger.info(f"[{name}] got successful response → stopping thread (stop_after_success)") + return # сколько уже заняло # elapsed = time.time() - start