Commit e913b3f6 authored by Jason Madden's avatar Jason Madden

Extract list of ignored exceptions in pywsgi to an ivar. Include...

Extract list of ignored exceptions in pywsgi to an ivar. Include errno.WSAECONNABORTED on Windows. Fixes #999.
parent 4d060427
...@@ -34,6 +34,10 @@ ...@@ -34,6 +34,10 @@
support in certain tools (setuptools v24.2.1 or newer is required). support in certain tools (setuptools v24.2.1 or newer is required).
See :issue:`995`. See :issue:`995`.
- pywgi also catches and ignores by default
:const:`errno.WSAECONNABORTED` on Windows. Initial patch in
:pr:`999` by Jan van Valburg.
1.2.2 (2017-06-05) 1.2.2 (2017-06-05)
================== ==================
......
...@@ -921,7 +921,33 @@ class WSGIHandler(object): ...@@ -921,7 +921,33 @@ class WSGIHandler(object):
close = None close = None
self.result = None self.result = None
#: These errors are silently ignored by :meth:`handle_one_response` to avoid producing
#: excess log entries on normal operating conditions. They indicate
#: a remote client has disconnected and there is little or nothing
#: this process can be expected to do about it. You may change this
#: value in a subclass.
#:
#: The default value includes :data:`errno.EPIPE` and :data:`errno.ECONNRESET`.
#: On Windows this also includes :data:`errno.WSAECONNABORTED`.
#:
#: This is a provisional API, subject to change. See :pr:`377`, :pr:`999`
#: and :issue:`136`.
#:
#: .. versionadded:: 1.3
ignored_socket_errors = (errno.EPIPE, errno.ECONNRESET)
try:
ignored_socket_errors += (errno.WSAECONNABORTED,)
except AttributeError:
pass # Not windows
def handle_one_response(self): def handle_one_response(self):
"""
Invoke the application to produce one response.
This is called by :meth:`handle_one_request` after all the
state for the request has been established. It is responsible
for error handling.
"""
self.time_start = time.time() self.time_start = time.time()
self.status = None self.status = None
self.headers_sent = False self.headers_sent = False
...@@ -946,12 +972,8 @@ class WSGIHandler(object): ...@@ -946,12 +972,8 @@ class WSGIHandler(object):
except _InvalidClientInput: except _InvalidClientInput:
self._send_error_response_if_possible(400) self._send_error_response_if_possible(400)
except socket.error as ex: except socket.error as ex:
if ex.args[0] in (errno.EPIPE, errno.ECONNRESET): if ex.args[0] in self.ignored_socket_errors:
# Broken pipe, connection reset by peer. # See description of self.ignored_socket_errors.
# Swallow these silently to avoid spewing
# useless info on normal operating conditions,
# bloating logfiles. See https://github.com/gevent/gevent/pull/377
# and https://github.com/gevent/gevent/issues/136.
if not PY3: if not PY3:
sys.exc_clear() sys.exc_clear()
self.close_connection = True self.close_connection = True
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment