Skip to content

Commit

Permalink
proxy: Use exceptions compatible with Python 3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
chfoo committed Jan 3, 2015
1 parent 98f8d44 commit 4d80214
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
What's New
==========

* Fixed NameError with PhantomJS proxy on Python 3.2.
* Fixed ``--page-requisites`` exceeding ``--level``.
* Fixed infinite page requisite recursion when using ``--span-hosts-allow page-requisites``.
* Added ``--page-requisites-level``. The default max recursion depth on page requisites is now 5.
Expand Down
13 changes: 9 additions & 4 deletions wpull/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ def __call__(self, reader, writer):
yield From(self._process_connection(reader, writer))
except Exception as error:
if not isinstance(error, StopIteration):
if isinstance(error, ConnectionError):
if isinstance(error, (trollius.ConnectionAbortedError,
trollius.ConnectionResetError)):
# Client using the proxy has closed the connection
_logger.debug('Proxy error', exc_info=True)
else:
_logger.exception('Proxy error')
Expand Down Expand Up @@ -159,9 +161,12 @@ def _start_tls(self, reader, writer):
try:
ssl_socket.do_handshake()
break
except (ssl.SSLWantReadError, ssl.SSLWantWriteError) as error:
_logger.debug('Do handshake %s', error)
yield From(trollius.sleep(0.05))
except ssl.SSLError as error:
if error.errno in (ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE):
_logger.debug('Do handshake %s', error)
yield From(trollius.sleep(0.05))
else:
raise
else:
_logger.error(_('Unable to handshake.'))
ssl_socket.close()
Expand Down

0 comments on commit 4d80214

Please sign in to comment.