Skip to content

Commit

Permalink
Merge pull request #2277 from JordanP/graceful-enotconn
Browse files Browse the repository at this point in the history
Do not raise and crash worker on ENOTCONN error
  • Loading branch information
tilgovi committed Dec 17, 2020
2 parents 548d582 + f8b1e84 commit b7f2a82
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion gunicorn/workers/base_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,13 @@ def handle(self, listener, client, addr):
self.log.debug("Error processing SSL request.")
self.handle_error(req, client, addr, e)
except EnvironmentError as e:
if e.errno not in (errno.EPIPE, errno.ECONNRESET):
if e.errno not in (errno.EPIPE, errno.ECONNRESET, errno.ENOTCONN):
self.log.exception("Socket error processing request.")
else:
if e.errno == errno.ECONNRESET:
self.log.debug("Ignoring connection reset")
elif e.errno == errno.ENOTCONN:
self.log.debug("Ignoring socket not connected")
else:
self.log.debug("Ignoring EPIPE")
except Exception as e:
Expand Down
4 changes: 3 additions & 1 deletion gunicorn/workers/gthread.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,13 @@ def handle(self, conn):
self.handle_error(req, conn.sock, conn.client, e)

except EnvironmentError as e:
if e.errno not in (errno.EPIPE, errno.ECONNRESET):
if e.errno not in (errno.EPIPE, errno.ECONNRESET, errno.ENOTCONN):
self.log.exception("Socket error processing request.")
else:
if e.errno == errno.ECONNRESET:
self.log.debug("Ignoring connection reset")
elif e.errno == errno.ENOTCONN:
self.log.debug("Ignoring socket not connected")
else:
self.log.debug("Ignoring connection epipe")
except Exception as e:
Expand Down
4 changes: 3 additions & 1 deletion gunicorn/workers/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,13 @@ def handle(self, listener, client, addr):
self.log.debug("Error processing SSL request.")
self.handle_error(req, client, addr, e)
except EnvironmentError as e:
if e.errno not in (errno.EPIPE, errno.ECONNRESET):
if e.errno not in (errno.EPIPE, errno.ECONNRESET, errno.ENOTCONN):
self.log.exception("Socket error processing request.")
else:
if e.errno == errno.ECONNRESET:
self.log.debug("Ignoring connection reset")
elif e.errno == errno.ENOTCONN:
self.log.debug("Ignoring socket not connected")
else:
self.log.debug("Ignoring EPIPE")
except Exception as e:
Expand Down

0 comments on commit b7f2a82

Please sign in to comment.