iq: only update the future if it is not done

This commit is contained in:
mathieui 2021-01-22 22:55:39 +01:00
parent b784b68bcd
commit 3f10dfe138

View file

@ -194,8 +194,10 @@ class Iq(RootStanza):
def callback_success(result):
type_ = result['type']
if type_ == 'result':
if not future.done():
future.set_result(result)
elif type_ == 'error':
if not future.done():
future.set_exception(IqError(result))
else:
# Most likely an iq addressed to ourself, rearm the callback.
@ -212,6 +214,7 @@ class Iq(RootStanza):
callback(result)
def callback_timeout():
if not future.done():
future.set_exception(IqTimeout(self))
self.stream.remove_handler('IqCallback_%s' % self['id'])
if timeout_callback is not None: