From f31baf4623fa3e92c7a524e1c86f91feec39e781 Mon Sep 17 00:00:00 2001 From: Richard Chien Date: Tue, 11 Dec 2018 11:17:57 +0800 Subject: [PATCH] Fix a bug --- none/command.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/none/command.py b/none/command.py index b82f7868..bbd792c8 100644 --- a/none/command.py +++ b/none/command.py @@ -516,12 +516,18 @@ async def _real_run_command(session: CommandSession, timeout = None if session.bot.config.SESSION_RUN_TIMEOUT: timeout = session.bot.config.SESSION_RUN_TIMEOUT.total_seconds() + try: await asyncio.wait_for(future, timeout) - raise _FinishException(future.result()) + handled = future.result() except asyncio.TimeoutError: - # if timeout happens, we think the session is finished - raise _FinishException(True) + # if timeout happens, absolutely the command was executed (but may not finished) + 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: session.running = False if disable_interaction: