From 3f10dfe138ee0be1c25e3e12546facd3a7b58651 Mon Sep 17 00:00:00 2001 From: mathieui Date: Fri, 22 Jan 2021 22:55:39 +0100 Subject: iq: only update the future if it is not done --- slixmpp/stanza/iq.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/slixmpp/stanza/iq.py b/slixmpp/stanza/iq.py index a3f16e2f..0f53425b 100644 --- a/slixmpp/stanza/iq.py +++ b/slixmpp/stanza/iq.py @@ -194,9 +194,11 @@ class Iq(RootStanza): def callback_success(result): type_ = result['type'] if type_ == 'result': - future.set_result(result) + if not future.done(): + future.set_result(result) elif type_ == 'error': - future.set_exception(IqError(result)) + if not future.done(): + future.set_exception(IqError(result)) else: # Most likely an iq addressed to ourself, rearm the callback. handler = constr(handler_name, @@ -212,7 +214,8 @@ class Iq(RootStanza): callback(result) def callback_timeout(): - future.set_exception(IqTimeout(self)) + if not future.done(): + future.set_exception(IqTimeout(self)) self.stream.remove_handler('IqCallback_%s' % self['id']) if timeout_callback is not None: timeout_callback(self) -- cgit v1.2.3