summaryrefslogtreecommitdiff
path: root/sleekxmpp/xmlstream
diff options
context:
space:
mode:
authorNathan Fritz <fritzy@netflint.net>2009-06-25 06:49:58 +0000
committerNathan Fritz <fritzy@netflint.net>2009-06-25 06:49:58 +0000
commitce8bf4a367af313dbf53e4a6ff2ee04a131f7cff (patch)
treed8cdfd7e9a40adea87e0957570b99e3469e6a6a8 /sleekxmpp/xmlstream
parent94f58ec3cbbc9c07ab517ed8ad1fdf3c1a3759f4 (diff)
downloadslixmpp-ce8bf4a367af313dbf53e4a6ff2ee04a131f7cff.tar.gz
slixmpp-ce8bf4a367af313dbf53e4a6ff2ee04a131f7cff.tar.bz2
slixmpp-ce8bf4a367af313dbf53e4a6ff2ee04a131f7cff.tar.xz
slixmpp-ce8bf4a367af313dbf53e4a6ff2ee04a131f7cff.zip
made disconnect cleaner
Diffstat (limited to 'sleekxmpp/xmlstream')
-rw-r--r--sleekxmpp/xmlstream/xmlstream.py34
1 files changed, 25 insertions, 9 deletions
diff --git a/sleekxmpp/xmlstream/xmlstream.py b/sleekxmpp/xmlstream/xmlstream.py
index e5d5f583..1c47d9ae 100644
--- a/sleekxmpp/xmlstream/xmlstream.py
+++ b/sleekxmpp/xmlstream/xmlstream.py
@@ -196,13 +196,25 @@ class XMLStream(object):
self.state.set('processing', False)
self.state.set('reconnect', False)
self.disconnect()
- raise
+ return
except CloseStream:
- break
+ return
+ except SystemExit:
+ return
+ except socket.EBADF:
+ if not self.state.reconnect:
+ return
+ else:
+ self.state.set('processing', False)
+ traceback.print_exc()
+ self.disconnect(reconnect=True)
except:
- self.state.set('processing', False)
- traceback.print_exc()
- self.disconnect(reconnect=True)
+ if not self.state.reconnect:
+ return
+ else:
+ self.state.set('processing', False)
+ traceback.print_exc()
+ self.disconnect(reconnect=True)
if self.state['reconnect']:
self.reconnect()
self.state.set('processing', False)
@@ -247,9 +259,10 @@ class XMLStream(object):
try:
self.socket.send(data)
except socket.error,(errno, strerror):
- logging.error("Disconnected. Socket Error #%s: %s" % (errno,strerror))
self.state.set('connected', False)
- self.disconnect(reconnect=True)
+ if self.state.reconnect:
+ logging.error("Disconnected. Socket Error #%s: %s" % (errno,strerror))
+ self.disconnect(reconnect=True)
return False
return True
@@ -264,9 +277,12 @@ class XMLStream(object):
self.filesocket.close()
self.socket.shutdown(socket.SHUT_RDWR)
except socket.error,(errno,strerror):
- logging.warning("Error while disconnecting. Socket Error #%s: %s" % (errno, strerror))
+ #logging.warning("Error while disconnecting. Socket Error #%s: %s" % (errno, strerror))
+ #thread.exit_thread()
+ pass
if self.state['processing']:
- raise CloseStream
+ #raise CloseStream
+ pass
def reconnect(self):
self.state.set('tls',False)