summaryrefslogtreecommitdiff
path: root/sleekxmpp/xmlstream
diff options
context:
space:
mode:
Diffstat (limited to 'sleekxmpp/xmlstream')
-rw-r--r--sleekxmpp/xmlstream/xmlstream.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/sleekxmpp/xmlstream/xmlstream.py b/sleekxmpp/xmlstream/xmlstream.py
index 6dbe7b30..a8bcac00 100644
--- a/sleekxmpp/xmlstream/xmlstream.py
+++ b/sleekxmpp/xmlstream/xmlstream.py
@@ -82,7 +82,7 @@ class XMLStream(object):
self.stream_footer = "</stream>"
self.eventqueue = queue.Queue()
- self.sendqueue = queue.Queue()
+ self.sendqueue = queue.PriorityQueue()
self.scheduler = scheduler.Scheduler(self.eventqueue)
self.namespace_map = {}
@@ -219,7 +219,7 @@ class XMLStream(object):
while self.run:
if not self.state.ensure('connected',wait=2): continue
try:
- self.sendRaw(self.stream_header)
+ self.sendPriorityRaw(self.stream_header)
while self.run and self.__readXML(): pass
except socket.timeout:
logging.debug('socket rcv timeout')
@@ -277,7 +277,7 @@ class XMLStream(object):
data = None
try:
- data = self.sendqueue.get(True,5)
+ data = self.sendqueue.get(True,5)[1]
logging.debug("SEND: %s" % data)
self.socket.sendall(data.encode('utf-8'))
except queue.Empty:
@@ -298,7 +298,11 @@ class XMLStream(object):
self.disconnect(reconnect=True)
def sendRaw(self, data):
- self.sendqueue.put(data)
+ self.sendqueue.put((1, data))
+ return True
+
+ def sendPriorityRaw(self, data):
+ self.sendqueue.put((0, data))
return True
def disconnect(self, reconnect=False):
@@ -306,7 +310,7 @@ class XMLStream(object):
logging.warning("Already disconnected.")
return
logging.debug("Disconnecting...")
- self.sendRaw(self.stream_footer)
+ self.sendPriorityRaw(self.stream_footer)
time.sleep(5)
#send end of stream
#wait for end of stream back