mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-11-24 03:00:15 +00:00
Cache stanza if sending fails.
The stanza will be sent first once the send queue is reactivated after session start. Stanzas sent by skipping the queue will not be cached.
This commit is contained in:
parent
a81162edd2
commit
1469323350
1 changed files with 10 additions and 4 deletions
|
@ -192,6 +192,7 @@ class XMLStream(object):
|
|||
|
||||
self.event_queue = queue.Queue()
|
||||
self.send_queue = queue.Queue()
|
||||
self.__failed_send_stanza = None
|
||||
self.scheduler = Scheduler(self.event_queue, self.stop)
|
||||
|
||||
self.namespace_map = {StanzaBase.xml_ns: 'xml'}
|
||||
|
@ -1021,6 +1022,10 @@ class XMLStream(object):
|
|||
try:
|
||||
while not self.stop.isSet():
|
||||
self.session_started_event.wait()
|
||||
if self.__failed_send_stanza is not None:
|
||||
data = self.__failed_send_stanza
|
||||
self.__failed_send_stanza = None
|
||||
else:
|
||||
try:
|
||||
data = self.send_queue.get(True, 1)
|
||||
except queue.Empty:
|
||||
|
@ -1031,6 +1036,7 @@ class XMLStream(object):
|
|||
except Socket.error as serr:
|
||||
self.event('socket_error', serr)
|
||||
log.warning("Failed to send %s" % data)
|
||||
self.__failed_send_stanza = data
|
||||
self.disconnect(self.auto_reconnect)
|
||||
except KeyboardInterrupt:
|
||||
log.debug("Keyboard Escape Detected in _send_thread")
|
||||
|
|
Loading…
Reference in a new issue