From 036550eb420f442cdc0d4f0aa280420b8e5a0e96 Mon Sep 17 00:00:00 2001 From: Jerry Date: Sat, 19 Jan 2019 15:11:12 +0800 Subject: [PATCH] release the lock at the right time --- tgmsbot.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tgmsbot.py b/tgmsbot.py index 2a8dd8d..f6cf8bc 100644 --- a/tgmsbot.py +++ b/tgmsbot.py @@ -347,15 +347,18 @@ def handle_button_click(bot, update): if board.state == 0: mmap = None board.move((row, col)) + if board.state != 1: + game.stopped = True game.lock.release() game.save_action(user, (row, col)) update_keyboard_request(bot, bhash, game, chat_id, msg.message_id) else: mmap = deepcopy(board.map) board.move((row, col)) + if board.state != 1: + game.stopped = True game.lock.release() - if board.state != 1: - game.stopped = True + # if this is the first move, there's no mmap if mmap is not None: game.save_action(user, (row, col))