iq: only update the future if it is not done
This commit is contained in:
parent
b784b68bcd
commit
3f10dfe138
1 changed files with 6 additions and 3 deletions
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue