This commit is contained in:
Alexey Barabanov
2025-10-20 13:33:37 +03:00
parent 55925f3847
commit e1aa4c993a
15 changed files with 22411 additions and 23816 deletions

View File

@@ -756,38 +756,38 @@ def Json_Team_Generation(who, data, stop_event):
player_season_stat = []
player_career_stat = []
coach_stat = []
# with ThreadPoolExecutor() as pool:
# player_season_stat_temp = [
# pool.submit(Player_Stat_Season, player_id, data["season"])
# for player_id in player_ids
# ]
# player_career_stat_temp = [
# pool.submit(Player_Stat_Career, player_id)
# for player_id in player_ids
# ]
# coach_stat_temp = [
# pool.submit(
# Coach_Stat, coach_id, data["season"], data[f"{who}_id"]
# )
# for coach_id in coach_ids
# ]
# player_futures = [pool.submit(Player_all_game, pid) for pid in player_ids]
# all_players_games = []
# for fut in as_completed(player_futures):
# try:
# all_players_games.append(fut.result())
# except Exception as e:
# logger.exception(f"Ошибка при обработке игрока: {e}")
with ThreadPoolExecutor() as pool:
player_season_stat_temp = [
pool.submit(Player_Stat_Season, player_id, data["season"])
for player_id in player_ids
]
player_career_stat_temp = [
pool.submit(Player_Stat_Career, player_id)
for player_id in player_ids
]
coach_stat_temp = [
pool.submit(
Coach_Stat, coach_id, data["season"], data[f"{who}_id"]
)
for coach_id in coach_ids
]
player_futures = [pool.submit(Player_all_game, pid) for pid in player_ids]
all_players_games = []
for fut in as_completed(player_futures):
try:
all_players_games.append(fut.result())
except Exception as e:
logger.exception(f"Ошибка при обработке игрока: {e}")
# player_season_stat += [
# res.result() for res in player_season_stat_temp
# ]
# player_career_stat += [
# res.result() for res in player_career_stat_temp
# ]
# coach_stat += [res.result() for res in coach_stat_temp]
player_season_stat += [
res.result() for res in player_season_stat_temp
]
player_career_stat += [
res.result() for res in player_career_stat_temp
]
coach_stat += [res.result() for res in coach_stat_temp]
# initialized = True
initialized = True
# print(coach_stat)
# while not stop_event.is_set():
role_list = [
@@ -2294,7 +2294,7 @@ def Play_By_Play(data: dict, stop_event: threading.Event) -> None:
json_live_status = get_json(url)
last_event = plays[-1]
if not json_live_status or json_live_status.get("message") == "Not Found":
if not json_live_status or json_live_status.get("status") == "Not Found":
period = last_event.get("period", 1)
second = 0
else:
@@ -2835,27 +2835,27 @@ def main():
args=("team1", data, stop_event),
name="Team1JSON",
),
# threading.Thread(
# target=Json_Team_Generation,
# args=("team2", data, stop_event),
# name="Team2JSON",
# ),
# threading.Thread(
# target=Team_Both_Stat, args=(stop_event,), name="BothTeamsStat"
# ),
# threading.Thread(target=Referee, args=(stop_event,), name="Referee"),
# threading.Thread(
# target=Scores_Quarter, args=(stop_event,), name="QuarterScore"
# ),
# threading.Thread(
# target=Status_Online, args=(data, stop_event), name="StatusOnline"
# ),
# threading.Thread(
# target=Play_By_Play, args=(data, stop_event), name="PlayByPlay"
# ),
# threading.Thread(
# target=Standing_func, args=(data, stop_event), name="Standings"
# ),
threading.Thread(
target=Json_Team_Generation,
args=("team2", data, stop_event),
name="Team2JSON",
),
threading.Thread(
target=Team_Both_Stat, args=(stop_event,), name="BothTeamsStat"
),
threading.Thread(target=Referee, args=(stop_event,), name="Referee"),
threading.Thread(
target=Scores_Quarter, args=(stop_event,), name="QuarterScore"
),
threading.Thread(
target=Status_Online, args=(data, stop_event), name="StatusOnline"
),
threading.Thread(
target=Play_By_Play, args=(data, stop_event), name="PlayByPlay"
),
threading.Thread(
target=Standing_func, args=(data, stop_event), name="Standings"
),
]
# Запуск всех потоков
@@ -2863,8 +2863,8 @@ def main():
t.start()
logger.debug(f"Поток {t.name} запущен.")
# How_To_Play_Quarter(data)
# pregame_data(data)
How_To_Play_Quarter(data)
pregame_data(data)
try:
while True: