Return the registered callback when using iq.send(callback=foo).

Allows for a callback to be canceled by unregistering the
returned handler.
This commit is contained in:
Lance Stout 2011-02-12 11:01:43 -05:00
parent 0d32638379
commit ca2b4a188a

View file

@ -195,7 +195,7 @@ class Iq(RootStanza):
once=True) once=True)
self.stream.register_handler(handler) self.stream.register_handler(handler)
StanzaBase.send(self) StanzaBase.send(self)
return None return handler
elif block and self['type'] in ('get', 'set'): elif block and self['type'] in ('get', 'set'):
waitfor = Waiter('IqWait_%s' % self['id'], MatcherId(self['id'])) waitfor = Waiter('IqWait_%s' % self['id'], MatcherId(self['id']))
self.stream.register_handler(waitfor) self.stream.register_handler(waitfor)