summaryrefslogtreecommitdiff
path: root/slixmpp/stanza
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2015-02-22 20:13:48 +0100
committermathieui <mathieui@mathieui.net>2015-02-22 20:13:48 +0100
commit06358d0665ee68962acef6936e063f4baadc1930 (patch)
tree5093461069b323ca9b24701c31cefd68cd048ade /slixmpp/stanza
parent2b3b86e281da03dfe4b2444be5b62811b4dcfe8d (diff)
downloadslixmpp-06358d0665ee68962acef6936e063f4baadc1930.tar.gz
slixmpp-06358d0665ee68962acef6936e063f4baadc1930.tar.bz2
slixmpp-06358d0665ee68962acef6936e063f4baadc1930.tar.xz
slixmpp-06358d0665ee68962acef6936e063f4baadc1930.zip
Use CallbackCoroutine with Iq callbacks too
Diffstat (limited to 'slixmpp/stanza')
-rw-r--r--slixmpp/stanza/iq.py22
1 files changed, 13 insertions, 9 deletions
diff --git a/slixmpp/stanza/iq.py b/slixmpp/stanza/iq.py
index e2cef50d..0d8051e2 100644
--- a/slixmpp/stanza/iq.py
+++ b/slixmpp/stanza/iq.py
@@ -8,7 +8,7 @@
from slixmpp.stanza.rootstanza import RootStanza
from slixmpp.xmlstream import StanzaBase, ET
-from slixmpp.xmlstream.handler import Waiter, Callback
+from slixmpp.xmlstream.handler import Waiter, Callback, CoroutineCallback
from slixmpp.xmlstream.asyncio import asyncio
from slixmpp.xmlstream.matcher import MatchIDSender, MatcherId
from slixmpp.exceptions import IqTimeout, IqError
@@ -249,6 +249,10 @@ class Iq(RootStanza):
if callback is not None and self['type'] in ('get', 'set'):
handler_name = 'IqCallback_%s' % self['id']
+ if asyncio.iscoroutinefunction(callback):
+ constr = CoroutineCallback
+ else:
+ constr = Callback
if timeout_callback:
self.callback = callback
self.timeout_callback = timeout_callback
@@ -256,15 +260,15 @@ class Iq(RootStanza):
timeout,
self._fire_timeout,
repeat=False)
- handler = Callback(handler_name,
- matcher,
- self._handle_result,
- once=True)
+ handler = constr(handler_name,
+ matcher,
+ self._handle_result,
+ once=True)
else:
- handler = Callback(handler_name,
- matcher,
- callback,
- once=True)
+ handler = constr(handler_name,
+ matcher,
+ callback,
+ once=True)
self.stream.register_handler(handler)
StanzaBase.send(self)
return handler_name