From 032129601471405085e22b11ea65631d01b40682 Mon Sep 17 00:00:00 2001 From: Stefan Rupp Date: Mon, 18 May 2020 21:13:51 +0200 Subject: [PATCH] needs to be a global variable, of course --- views/player.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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: