diff options
author | Lance Stout <lancestout@gmail.com> | 2014-08-17 17:20:26 -0700 |
---|---|---|
committer | Lance Stout <lancestout@gmail.com> | 2014-08-17 17:20:26 -0700 |
commit | ca306e7cecee4bf7afd9ce44f5f067b305928682 (patch) | |
tree | 3641ff7754a221a53d6b5af08ffefa3f6898627d /sleekxmpp/xmlstream | |
parent | a5c03b763a6545a214f4f391f7c07582c22150b2 (diff) | |
parent | 1bf34f7fe694c2997710e0d23b0784e824df5e5e (diff) | |
download | slixmpp-ca306e7cecee4bf7afd9ce44f5f067b305928682.tar.gz slixmpp-ca306e7cecee4bf7afd9ce44f5f067b305928682.tar.bz2 slixmpp-ca306e7cecee4bf7afd9ce44f5f067b305928682.tar.xz slixmpp-ca306e7cecee4bf7afd9ce44f5f067b305928682.zip |
Merge pull request #310 from Mayflower/cleanup
Cleanup
Diffstat (limited to 'sleekxmpp/xmlstream')
-rw-r--r-- | sleekxmpp/xmlstream/xmlstream.py | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/sleekxmpp/xmlstream/xmlstream.py b/sleekxmpp/xmlstream/xmlstream.py index 66985f3d..a871238a 100644 --- a/sleekxmpp/xmlstream/xmlstream.py +++ b/sleekxmpp/xmlstream/xmlstream.py @@ -853,7 +853,7 @@ class XMLStream(object): if sys.version_info >= (2, 7): ssl_args['ciphers'] = self.ciphers - ssl_socket = ssl.wrap_socket(self.socket, **ssl_args); + ssl_socket = ssl.wrap_socket(self.socket, **ssl_args) if hasattr(self.socket, 'socket'): # We are using a testing socket, so preserve the top @@ -1148,7 +1148,7 @@ class XMLStream(object): """ return len(self.__event_handlers.get(name, [])) - def event(self, name, data={}, direct=False): + def event(self, name, data=None, direct=False): """Manually trigger a custom event. :param name: The name of the event to trigger. @@ -1159,6 +1159,9 @@ class XMLStream(object): event queue. All event handlers will run in the same thread. """ + if not data: + data = {} + log.debug("Event triggered: " + name) handlers = self.__event_handlers.get(name, []) @@ -1318,9 +1321,6 @@ class XMLStream(object): try: sent += self.socket.send(data[sent:]) count += 1 - except Socket.error as serr: - if serr.errno != errno.EINTR: - raise except ssl.SSLError as serr: if tries >= self.ssl_retry_max: log.debug('SSL error: max retries reached') @@ -1335,6 +1335,9 @@ class XMLStream(object): if not self.stop.is_set(): time.sleep(self.ssl_retry_delay) tries += 1 + except Socket.error as serr: + if serr.errno != errno.EINTR: + raise if count > 1: log.debug('SENT: %d chunks', count) except (Socket.error, ssl.SSLError) as serr: @@ -1744,9 +1747,6 @@ class XMLStream(object): try: sent += self.socket.send(enc_data[sent:]) count += 1 - except Socket.error as serr: - if serr.errno != errno.EINTR: - raise except ssl.SSLError as serr: if tries >= self.ssl_retry_max: log.debug('SSL error: max retries reached') @@ -1759,6 +1759,9 @@ class XMLStream(object): if not self.stop.is_set(): time.sleep(self.ssl_retry_delay) tries += 1 + except Socket.error as serr: + if serr.errno != errno.EINTR: + raise if count > 1: log.debug('SENT: %d chunks', count) self.send_queue.task_done() |