diff options
author | Lance Stout <lancestout@gmail.com> | 2011-02-13 16:30:57 -0500 |
---|---|---|
committer | Lance Stout <lancestout@gmail.com> | 2011-02-13 16:30:57 -0500 |
commit | 34f6195ca5a042ac61aa20af0b339a6654e2ffdd (patch) | |
tree | 4e38c5b28177844070436086fdf74df7381cb66f /sleekxmpp/stanza | |
parent | 70af52d74c3f4253791120be4016f108aa966b4d (diff) | |
download | slixmpp-34f6195ca5a042ac61aa20af0b339a6654e2ffdd.tar.gz slixmpp-34f6195ca5a042ac61aa20af0b339a6654e2ffdd.tar.bz2 slixmpp-34f6195ca5a042ac61aa20af0b339a6654e2ffdd.tar.xz slixmpp-34f6195ca5a042ac61aa20af0b339a6654e2ffdd.zip |
Return the name of the registered callback.
Instead of the actual callback object, return just the name of
the callback object created when using iq.send(callback=..).
This will help prevent memory leaks by not keeping an additional
reference to the object, but still allows for the callback to be
canceled by using self.remove_handler("handler_name").
Diffstat (limited to 'sleekxmpp/stanza')
-rw-r--r-- | sleekxmpp/stanza/iq.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/sleekxmpp/stanza/iq.py b/sleekxmpp/stanza/iq.py index 7a8b997b..330df6c2 100644 --- a/sleekxmpp/stanza/iq.py +++ b/sleekxmpp/stanza/iq.py @@ -189,13 +189,14 @@ class Iq(RootStanza): if timeout is None: timeout = self.stream.response_timeout if callback is not None and self['type'] in ('get', 'set'): - handler = Callback('IqCallback_%s' % self['id'], + handler_name = 'IqCallback_%s' % self['id'] + handler = Callback(handler_name, MatcherId(self['id']), callback, once=True) self.stream.register_handler(handler) StanzaBase.send(self) - return handler + return handler_name elif block and self['type'] in ('get', 'set'): waitfor = Waiter('IqWait_%s' % self['id'], MatcherId(self['id'])) self.stream.register_handler(waitfor) |