diff options
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | 2018-03-14 17:37:55 +0100 |
---|---|---|
committer | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | 2018-03-14 17:37:55 +0100 |
commit | 51847133560e9ef6aaa3d13578fcdf87cb049b32 (patch) | |
tree | c3e91dfbd1b63f0058b7d6837fbeffcee4441970 | |
parent | 2f1225bad3d89f03a3251696abd7e30807ca4d6b (diff) | |
download | slixmpp-51847133560e9ef6aaa3d13578fcdf87cb049b32.tar.gz slixmpp-51847133560e9ef6aaa3d13578fcdf87cb049b32.tar.bz2 slixmpp-51847133560e9ef6aaa3d13578fcdf87cb049b32.tar.xz slixmpp-51847133560e9ef6aaa3d13578fcdf87cb049b32.zip |
Rearm an iq callback if it was addressed to ourself.
-rw-r--r-- | slixmpp/stanza/iq.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/slixmpp/stanza/iq.py b/slixmpp/stanza/iq.py index af7e3109..385bbbd9 100644 --- a/slixmpp/stanza/iq.py +++ b/slixmpp/stanza/iq.py @@ -188,10 +188,19 @@ class Iq(RootStanza): future = asyncio.Future() def callback_success(result): - if result['type'] == 'error': + type_ = result['type'] + if type_ == 'result': + future.set_result(result) + elif type_ == 'error': future.set_exception(IqError(result)) else: - future.set_result(result) + # Most likely an iq addressed to ourself, rearm the callback. + handler = constr(handler_name, + matcher, + callback_success, + once=True) + self.stream.register_handler(handler) + return if timeout is not None: self.stream.cancel_schedule('IqTimeout_%s' % self['id']) |