mirror of
https://github.com/nonebot/nonebot2.git
synced 2024-11-28 08:12:14 +08:00
Fix a bug
This commit is contained in:
parent
8e877b6cd3
commit
f31baf4623
@ -516,12 +516,18 @@ async def _real_run_command(session: CommandSession,
|
|||||||
timeout = None
|
timeout = None
|
||||||
if session.bot.config.SESSION_RUN_TIMEOUT:
|
if session.bot.config.SESSION_RUN_TIMEOUT:
|
||||||
timeout = session.bot.config.SESSION_RUN_TIMEOUT.total_seconds()
|
timeout = session.bot.config.SESSION_RUN_TIMEOUT.total_seconds()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await asyncio.wait_for(future, timeout)
|
await asyncio.wait_for(future, timeout)
|
||||||
raise _FinishException(future.result())
|
handled = future.result()
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
# if timeout happens, we think the session is finished
|
# if timeout happens, absolutely the command was executed (but may not finished)
|
||||||
raise _FinishException(True)
|
handled = True
|
||||||
|
except Exception as e:
|
||||||
|
# if any other exception happens, the command was executed but failed
|
||||||
|
logger.exception(e)
|
||||||
|
handled = True
|
||||||
|
raise _FinishException(handled)
|
||||||
except _FurtherInteractionNeeded:
|
except _FurtherInteractionNeeded:
|
||||||
session.running = False
|
session.running = False
|
||||||
if disable_interaction:
|
if disable_interaction:
|
||||||
|
Loading…
Reference in New Issue
Block a user