From 3791560456f6646f9c531b27712b991131050363 Mon Sep 17 00:00:00 2001 From: Richard Chien Date: Fri, 27 Jul 2018 22:53:59 +0800 Subject: [PATCH] Add waiting when the current session is running --- none/command.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/none/command.py b/none/command.py index ccd0dbbd..819b232b 100644 --- a/none/command.py +++ b/none/command.py @@ -404,6 +404,13 @@ async def handle_command(bot: NoneBot, ctx: Dict[str, Any]) -> bool: check_perm = True if _sessions.get(ctx_id): session = _sessions[ctx_id] + + # wait for 1.5 seconds (at most) if the current session is running + retry = 5 + while session.running and retry > 0: + retry -= 1 + await asyncio.sleep(0.3) + if session.running: logger.warning(f'There is a session of command ' f'{session.cmd.name} running, notify the user')