Don't use the send queue for stream initialization.

Use the parameter now=True to skip the queue when
sending Iq stanzas, or using xmpp.send().
This commit is contained in:
Lance Stout
2011-05-27 16:59:52 -07:00
parent 6997b2fbf8
commit 1735c194cd
6 changed files with 70 additions and 33 deletions

View File

@@ -154,7 +154,7 @@ class Iq(RootStanza):
StanzaBase.reply(self, clear)
return self
def send(self, block=True, timeout=None, callback=None):
def send(self, block=True, timeout=None, callback=None, now=False):
"""
Send an <iq> stanza over the XML stream.
@@ -178,6 +178,9 @@ class Iq(RootStanza):
Defaults to sleekxmpp.xmlstream.RESPONSE_TIMEOUT
callback -- Optional reference to a stream handler function. Will
be executed when a reply stanza is received.
now -- Indicates if the send queue should be skipped and send
the stanza immediately. Used during stream
initialization. Defaults to False.
"""
if timeout is None:
timeout = self.stream.response_timeout
@@ -188,15 +191,15 @@ class Iq(RootStanza):
callback,
once=True)
self.stream.register_handler(handler)
StanzaBase.send(self)
StanzaBase.send(self, now=now)
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)
StanzaBase.send(self)
StanzaBase.send(self, now=now)
return waitfor.wait(timeout)
else:
return StanzaBase.send(self)
return StanzaBase.send(self, now=now)
def _set_stanza_values(self, values):
"""