diff --git a/get_data.py b/get_data.py index 4f22f98..235405d 100644 --- a/get_data.py +++ b/get_data.py @@ -29,7 +29,7 @@ args = parser.parse_args() LEAGUE = args.league TEAM = args.team LANG = args.lang -HOST = "https://ref.russiabasket.org" +HOST = "https://pro.russiabasket.org" STATUS = False GAME_ID = None SEASON = None @@ -70,7 +70,7 @@ def get_data_from_API( while not stop_event.is_set(): start = time.time() try: - value = requests.get(url).json() + value = requests.get(url, timeout=5).json() except Exception as ex: value = {"error": str(ex)} ts = datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")[:-3] @@ -433,7 +433,7 @@ async def lifespan(app: FastAPI): args=( "live-status", URLS["live-status"].format(host=HOST, game_id=game_id), - 3, + 1, stop_event, ), daemon=True, @@ -443,7 +443,7 @@ async def lifespan(app: FastAPI): args=( "box-score", URLS["box-score"].format(host=HOST, game_id=game_id), - 3, + 1, stop_event, ), daemon=True, @@ -453,7 +453,7 @@ async def lifespan(app: FastAPI): args=( "play-by-play", URLS["play-by-play"].format(host=HOST, game_id=game_id), - 3, + 1, stop_event, ), daemon=True, @@ -528,12 +528,11 @@ async def lifespan(app: FastAPI): # -------- shutdown -------- stop_event.set() - thread_result_consumer.join(timeout=1) # офлайн/онлайн ты можешь не делить тут, но оставлю - for t in threads_offline: - t.join(timeout=1) - for t in threads_live: + stop_event.set() + for t in threads_live + threads_offline: t.join(timeout=1) + thread_result_consumer.join(timeout=1) app = FastAPI(lifespan=lifespan)