Prevent exceptions from destroying the ELO tracker scheduled loop

sam/sneaky
Bram van den Heuvel 2026-06-28 13:48:42 +02:00
parent 6cd1ec9c97
commit 87525238ba
3 changed files with 6 additions and 3 deletions

View File

@ -93,7 +93,7 @@ class RemoteAgent(Agent):
response = requests.get(url, json=payload, timeout=self.timeout) response = requests.get(url, json=payload, timeout=self.timeout)
response.raise_for_status() response.raise_for_status()
content = response.json() content = response.json()
except (requests.RequestException, requests.HTTPError, ValueError): except (requests.ConnectTimeout, requests.RequestException, requests.HTTPError, ValueError):
return {} return {}
else: else:
return content if isinstance(content, dict) else {} return content if isinstance(content, dict) else {}

View File

@ -460,7 +460,7 @@ class EloTracker:
self.play_random_match(game=game, player_count=player_count) self.play_random_match(game=game, player_count=player_count)
except Exception as exc: except Exception as exc:
self.__debug(f"Scheduled match failed: {exc}") self.__debug(f"Scheduled match failed: {exc}")
raise exc # raise exc
if self.__scheduler_stop.wait(interval_seconds): if self.__scheduler_stop.wait(interval_seconds):
break break

View File

@ -52,7 +52,10 @@ class PyClient:
if on_move is None: if on_move is None:
payload = {} payload = {}
else: else:
payload = on_move(current_state.as_seen_by(player=player)) try:
payload = on_move(current_state.as_seen_by(player=player))
except Exception:
payload = {}
current_state = current_state.move(payload=payload) current_state = current_state.move(payload=payload)