исправил host на pro и поправил тайм-аут на лайв-треде на 1 с

This commit is contained in:
2025-10-31 18:47:30 +03:00
parent aff438a1f3
commit 9e484b3493

View File

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