mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-11-27 19:19:54 +00:00
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").
This commit is contained in:
parent
70af52d74c
commit
34f6195ca5
1 changed files with 3 additions and 2 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue