diff options
author | Lance Stout <lancestout@gmail.com> | 2012-04-13 08:27:11 -0400 |
---|---|---|
committer | Lance Stout <lancestout@gmail.com> | 2012-04-13 08:27:11 -0400 |
commit | 94aa6673cab5bf79648ac666dc62f48b064bb845 (patch) | |
tree | 902bcc0cac2cc6d7f425c68c036e624c1814929e /sleekxmpp/xmlstream | |
parent | 4b2b2d16b8f7999a7d6daee2f3e1811ba7d3c381 (diff) | |
download | slixmpp-94aa6673cab5bf79648ac666dc62f48b064bb845.tar.gz slixmpp-94aa6673cab5bf79648ac666dc62f48b064bb845.tar.bz2 slixmpp-94aa6673cab5bf79648ac666dc62f48b064bb845.tar.xz slixmpp-94aa6673cab5bf79648ac666dc62f48b064bb845.zip |
Check for the stop event more aggressively in the send thread.
Diffstat (limited to 'sleekxmpp/xmlstream')
-rw-r--r-- | sleekxmpp/xmlstream/xmlstream.py | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/sleekxmpp/xmlstream/xmlstream.py b/sleekxmpp/xmlstream/xmlstream.py index 808464f0..891f275a 100644 --- a/sleekxmpp/xmlstream/xmlstream.py +++ b/sleekxmpp/xmlstream/xmlstream.py @@ -630,6 +630,8 @@ class XMLStream(object): # Clearing this event will pause the send loop. self.session_started_event.clear() + self.__failed_send_stanza = None + # Send the end of stream marker. if send_close: self.send_raw(self.stream_footer, now=True) @@ -1152,9 +1154,11 @@ class XMLStream(object): log.warning("Failed to send %s", data) if reconnect is None: reconnect = self.auto_reconnect - self.disconnect(reconnect, send_close=False) + if not self.stop.is_set(): + self.disconnect(reconnect, send_close=False) log.warning('SSL write error - reattempting') - time.sleep(self.ssl_retry_delay) + if not self.stop.is_set(): + time.sleep(self.ssl_retry_delay) tries += 1 if count > 1: log.debug('SENT: %d chunks', count) @@ -1163,7 +1167,8 @@ class XMLStream(object): log.warning("Failed to send %s", data) if reconnect is None: reconnect = self.auto_reconnect - self.disconnect(reconnect, send_close=False) + if not self.stop.is_set(): + self.disconnect(reconnect, send_close=False) else: self.send_queue.put(data) return True @@ -1501,9 +1506,11 @@ class XMLStream(object): log.debug('SSL error - max retries reached') self.exception(serr) log.warning("Failed to send %s", data) - self.disconnect(self.auto_reconnect, send_close=False) + if not self.stop.is_set(): + self.disconnect(self.auto_reconnect, send_close=False) log.warning('SSL write error - reattempting') - time.sleep(self.ssl_retry_delay) + if not self.stop.is_set(): + time.sleep(self.ssl_retry_delay) tries += 1 if count > 1: log.debug('SENT: %d chunks', count) @@ -1511,8 +1518,9 @@ class XMLStream(object): except Socket.error as serr: self.event('socket_error', serr, direct=True) log.warning("Failed to send %s", data) - self.__failed_send_stanza = data - self.disconnect(self.auto_reconnect, send_close=False) + if not self.stop.is_set(): + self.__failed_send_stanza = data + self.disconnect(self.auto_reconnect, send_close=False) except Exception as ex: log.exception('Unexpected error in send thread: %s', ex) self.exception(ex) |