diff --git a/views/player.py b/views/player.py index 18912da..7e947db 100644 --- a/views/player.py +++ b/views/player.py @@ -4,6 +4,11 @@ from wiz_game import the_game from starlette.websockets import WebSocketDisconnect import asyncio + +playing_lock = asyncio.Lock() + + + @api.route("/player/{player}") def show(req, resp, player: str): p = int(player) @@ -31,11 +36,11 @@ def show(req, resp, player: str): @api.route("/player/{player}/play/{card}") async def play(req, resp, player: str, card: str): - lock = asyncio.Lock() p = int(player) c = int(card) - async with lock: + global playing_lock + async with playing_lock: try: isActive = the_game.players_ordered[the_game.active_player].id == p except IndexError: