mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-01-19 17:58:26 +08:00
Add waiting when the current session is running
This commit is contained in:
parent
7b96decf53
commit
3791560456
@ -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')
|
||||
|
Loading…
Reference in New Issue
Block a user