summaryrefslogtreecommitdiff
path: root/sleekxmpp/xmlstream
diff options
context:
space:
mode:
authorThom Nichols <tmnichols@gmail.com>2010-07-02 18:05:50 -0400
committerThom Nichols <tmnichols@gmail.com>2010-07-02 18:05:50 -0400
commit0a30e6c0175b13cef400d4cba27eaf145b07d365 (patch)
treea9e8e70511b85bdac6bf91d99cd9e5552bd4e9cd /sleekxmpp/xmlstream
parentd381ab320aa8c285d80b0384c8bbaf461639e366 (diff)
downloadslixmpp-0a30e6c0175b13cef400d4cba27eaf145b07d365.tar.gz
slixmpp-0a30e6c0175b13cef400d4cba27eaf145b07d365.tar.bz2
slixmpp-0a30e6c0175b13cef400d4cba27eaf145b07d365.tar.xz
slixmpp-0a30e6c0175b13cef400d4cba27eaf145b07d365.zip
cleaned up disconnect/reconnect logic just a little
Diffstat (limited to 'sleekxmpp/xmlstream')
-rw-r--r--sleekxmpp/xmlstream/xmlstream.py17
1 files changed, 5 insertions, 12 deletions
diff --git a/sleekxmpp/xmlstream/xmlstream.py b/sleekxmpp/xmlstream/xmlstream.py
index 88ec219c..fd0b0fa0 100644
--- a/sleekxmpp/xmlstream/xmlstream.py
+++ b/sleekxmpp/xmlstream/xmlstream.py
@@ -219,7 +219,6 @@ class XMLStream(object):
while not self.quit.is_set():
if not self.state.ensure('connected',wait=2, block_on_transition=True): continue
try:
- logging.debug(' ------------------------------- starting process loop...')
self.sendPriorityRaw(self.stream_header)
self.__readXML() # this loops until the stream is terminated.
except socket.timeout:
@@ -239,15 +238,9 @@ class XMLStream(object):
# if the RCV socket is terminated for whatever reason (e.g. we reach this point of
# code,) our only sane choice of action is an attempt to re-establish the connection.
- if not self.quit.is_set():
- logging.info( 'about to reconnect..........' )
- try:
- self.disconnect(reconnect=self.should_reconnect, error=True)
- except:
- logging.exception( "WTF disconnect!" )
- logging.info( 'reconnect complete!' )
- logging.info( 'reconnect complete!' )
-
+ reconnect = (self.should_reconnect and not self.quit.is_set())
+ self.disconnect(reconnect=reconnect, error=True)
+
logging.debug('Quitting Process thread')
def __readXML(self):
@@ -303,8 +296,8 @@ class XMLStream(object):
# the same thing concurrently. Oops! The safer option would be to throw
# some sort of event that could be handled by a common thread or the reader
# thread to perform reconnect and then re-initialize the handler threads as well.
- if self.should_reconnect:
- self.disconnect(reconnect=True, error=True)
+ reconnect = (self.should_reconnect and not self.quit.is_set())
+ self.disconnect(reconnect=reconnect, error=True)
def sendRaw(self, data):
self.sendqueue.put((1, data))