Fix a bug

This commit is contained in:
Richard Chien 2018-12-11 11:17:57 +08:00
parent 8e877b6cd3
commit f31baf4623

View File

@ -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: