Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch ConnectionError instead of socket.error on Python 3 #1418

merged 1 commit into from Dec 10, 2018


Copy link

PEP 3151 made socket.error an alias of OSError on Python 3. Our server was catching socket.error to silence client disconnects (and any other socket-related errors), but on Python 3 this silences all OSErrors.

I'm not clear why socket.error is an alias for OSError instead of ConnectionError. If that were the case, the code would have worked correctly without change. This section in PEP 3151 seems to imply the same.

This change catches ConnectionError on Python 3, and continues to catch socket.error on Python 2. Additionally, handle_error also checks for socket errors, since they weren't completely silenced on Python 2.

Closes #1127

@davidism davidism added this to the 0.15 milestone Dec 10, 2018
@davidism davidism merged commit a8692e2 into master Dec 10, 2018
@davidism davidism deleted the socket-error branch December 10, 2018 01:06
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet

Successfully merging this pull request may close these issues.

When WSGIRequestHandler catches socket.error it silences all other OSErrors in Python 3
1 participant