Skip to content

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

Merged
davidism merged 1 commit into
masterfrom
socket-error
Dec 10, 2018
Merged

Catch ConnectionError instead of socket.error on Python 3#1418
davidism merged 1 commit into
masterfrom
socket-error

Conversation

@davidism

Copy link
Copy Markdown
Member

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.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant