perf(battlesnake): defer ordered lifecycle bookkeeping
Build and Push Docker Container / build-and-push (push) Successful in 10m12s
Build and Push Docker Container / build-and-push (push) Successful in 10m12s
- Acknowledge start and end without waiting for persistence or dashboards. - Keep runtime creation and finished-game removal on the response path. - Serialize start, turn, and end bookkeeping per game in Quart tasks. - Capture turn thinking before scheduling deferred persistence. - Defer start metrics, logging, and stale-game pruning. - Run legacy history exports in a worker thread. - Record results and end metrics even when history export fails. - Drain pending bookkeeping before closing storage during shutdown. - Test sub-500 ms responses with slow backends and real SQLite. - Cover event ordering, export failures, and rejected user agents.
This commit is contained in:
@@ -23,10 +23,13 @@ class GameplayTrackingService:
|
||||
await await_log(self.logger.warning(f"Gameplay DB start record failed:{error}"))
|
||||
|
||||
async def record_gameplay_turn(self, game_state:dict, my_move:str, game_board:GameBoard) -> None:
|
||||
thinking = self._extract_latest_snake_thinking(game_board)
|
||||
await self.record_gameplay_turn_snapshot(game_state, my_move, thinking)
|
||||
|
||||
async def record_gameplay_turn_snapshot(self, game_state:dict, my_move:str|None, thinking:dict|None) -> None:
|
||||
if self.gameplay_database is None:
|
||||
return
|
||||
try:
|
||||
thinking = self._extract_latest_snake_thinking(game_board)
|
||||
await self.gameplay_database.record_turn(game_state, my_move, thinking)
|
||||
except Exception as error:
|
||||
await await_log(self.logger.warning(f"Gameplay DB turn record failed:{error}"))
|
||||
|
||||
Reference in New Issue
Block a user