reconnection fix: xmlstream now catches XMLParserError and restarts the stream
This commit is contained in:
parent
fe1d3004cc
commit
4b00baab1e
@ -42,9 +42,6 @@ if sys.version_info < (3, 0):
|
|||||||
class RestartStream(Exception):
|
class RestartStream(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class CloseStream(Exception):
|
|
||||||
pass
|
|
||||||
|
|
||||||
stanza_extensions = {}
|
stanza_extensions = {}
|
||||||
|
|
||||||
RECONNECT_MAX_DELAY = 3600
|
RECONNECT_MAX_DELAY = 3600
|
||||||
@ -225,9 +222,6 @@ class XMLStream(object):
|
|||||||
except socket.timeout:
|
except socket.timeout:
|
||||||
logging.debug('socket rcv timeout')
|
logging.debug('socket rcv timeout')
|
||||||
pass
|
pass
|
||||||
except CloseStream:
|
|
||||||
# TODO warn that the listener thread is exiting!!!
|
|
||||||
pass
|
|
||||||
except RestartStream:
|
except RestartStream:
|
||||||
logging.debug("Restarting stream...")
|
logging.debug("Restarting stream...")
|
||||||
continue # DON'T re-initialize the stream -- this exception is sent
|
continue # DON'T re-initialize the stream -- this exception is sent
|
||||||
@ -236,13 +230,14 @@ class XMLStream(object):
|
|||||||
logging.debug("System interrupt detected")
|
logging.debug("System interrupt detected")
|
||||||
self.shutdown()
|
self.shutdown()
|
||||||
self.eventqueue.put(('quit', None, None))
|
self.eventqueue.put(('quit', None, None))
|
||||||
except cElementTree.XMLParserError:
|
except cElementTree.XMLParserError: #if there is an xml parsing exception, assume stream needs to be restarted
|
||||||
logging.warn('XML RCV parsing error!', exc_info=1)
|
logging.warn('XML RCV parsing error!', exc_info=1)
|
||||||
# don't restart the stream on an XML parse error.
|
if self.should_reconnect: self.disconnect(reconnect=True)
|
||||||
|
else: self.disconnect()
|
||||||
except:
|
except:
|
||||||
logging.exception('Unexpected error in RCV thread')
|
logging.exception('Unexpected error in RCV thread')
|
||||||
if self.should_reconnect:
|
if self.should_reconnect: self.disconnect(reconnect=True)
|
||||||
self.disconnect(reconnect=True)
|
else: self.disconnect()
|
||||||
|
|
||||||
logging.debug('Quitting Process thread')
|
logging.debug('Quitting Process thread')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user