prevent dead lock

This commit is contained in:
JerryXiao 2019-03-01 17:06:38 +08:00
parent c2b1b81b2b
commit 864c72f6ce
Signed by: Jerry
GPG key ID: 9D9CE43650FF2BAA

View file

@ -341,6 +341,7 @@ def handle_button_click(bot, update):
logger.debug("No game found for hash {}".format(bhash))
return
game.lock.acquire()
try:
if game.stopped:
return
board = game.board
@ -396,6 +397,12 @@ def handle_button_click(bot, update):
update_keyboard_request(bot, bhash, game, chat_id, msg.message_id)
else:
game.lock.release()
except:
try:
game.lock.release()
except RuntimeError:
pass
raise