mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-12-23 06:50:29 +01:00
Make ConversationHandler and run_async work together properly (#1176)
* #1175 * fix issue with timeout * exception in promise resolve is treated as None result * removed useless variables
This commit is contained in:
parent
bbe633e571
commit
b8c288ff4a
1 changed files with 11 additions and 12 deletions
|
@ -230,18 +230,17 @@ class ConversationHandler(Handler):
|
||||||
self.logger.debug('waiting for promise...')
|
self.logger.debug('waiting for promise...')
|
||||||
|
|
||||||
old_state, new_state = state
|
old_state, new_state = state
|
||||||
error = False
|
if new_state.done.wait(timeout=self.run_async_timeout):
|
||||||
try:
|
try:
|
||||||
res = new_state.result(timeout=self.run_async_timeout)
|
res = new_state.result(timeout=0)
|
||||||
except Exception as exc:
|
res = res if res is not None else old_state
|
||||||
self.logger.exception("Promise function raised exception")
|
except Exception as exc:
|
||||||
self.logger.exception("{}".format(exc))
|
self.logger.exception("Promise function raised exception")
|
||||||
error = True
|
self.logger.exception("{}".format(exc))
|
||||||
|
res = old_state
|
||||||
if not error and new_state.done.is_set():
|
finally:
|
||||||
self.update_state(res, key)
|
self.update_state(res, key)
|
||||||
state = self.conversations.get(key)
|
state = self.conversations.get(key)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
for candidate in (self.timed_out_behavior or []):
|
for candidate in (self.timed_out_behavior or []):
|
||||||
if candidate.check_update(update):
|
if candidate.check_update(update):
|
||||||
|
|
Loading…
Reference in a new issue