Cancel CPU turns immediately when host ends game
Convert CPU turn chain to a cancellable asyncio.Task tracked on Room, so ending the game or leaving no longer blocks waiting for CPU sleeps. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1934,7 +1934,11 @@ def _log_cpu_action(logger, game_id: Optional[str], cpu_player: Player, game: Ga
|
||||
async def process_cpu_turn(
|
||||
game: Game, cpu_player: Player, broadcast_callback, game_id: Optional[str] = None
|
||||
) -> None:
|
||||
"""Process a complete turn for a CPU player."""
|
||||
"""Process a complete turn for a CPU player.
|
||||
|
||||
May raise asyncio.CancelledError if the game is ended mid-turn.
|
||||
The caller (check_and_run_cpu_turn) handles cancellation.
|
||||
"""
|
||||
import asyncio
|
||||
from services.game_logger import get_logger
|
||||
|
||||
|
||||
Reference in New Issue
Block a user