Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Suppress [Errno 10053] errors (Windows) #999
This prevents pywsgi from printing stack traces when the client disconnects from the server.
When running pywsgi on Windows I am seeing a lot of these stack traces:
I can see that we are already suppressing EPIPE and ECONNRESET errors, but on Windows there is also the WSAECONNABORTED which needs to be suppressed.
The reason that we feel good about swallowing EPIPE and ECONNRESET is that they're usually caused by the remote machine hanging up, i.e., the client timed out and quit, or lost its connection, or whatever. But the error message here ("connection was aborted by the software in your host machine") seems to suggest that it's the local machine/process that's at fault, which sounds very different and more concerning to me---I would want to see if there was something I needed to adjust locally to stop those errors.
Then there's the fact that the
Instead we could use a value on self:
class Server(object): swallowed_connection_abort_errnos = (errno.EPIPE, errno.ECONNRESET) if hasattr(errno, 'WSAwhatever'): swallowed_connection_abort_ernos += (errno.WSAwhatever,) ... def ...: if ex.args in self.swallowed_connection_abort_errnos: # swallow
I like that approach for a few reasons. One is that it gives us a place to use a doc-comment so we can document what we're doing and why. Another is that we could actually leave out WSAwhetever (if it truly is of a different kind than the other caught exceptions) and allow users to subclass or set an instance variable if they did need to catch it.
I'm happy to do the first part for sure (extract to a ivar and document).
Great! Thank you for your comments
Your suggestion of extracting the list of exceptions into a variable makes complete sense. I didn't realise that WSA* was a Windows-only exception although it seems obvious now that you mention it.
The Windows "connection was aborted by the software in your host machine" error is rather badly worded. It sounds like something has gone wrong with the local machine, but it actually means that the remote client closed the connection while our server was writing to it.
Some further explanation is here: