From fa9d028d0966112a79df6640780e7948e75d961b Mon Sep 17 00:00:00 2001 From: Randall Leeds Date: Wed, 7 Aug 2013 19:57:56 -0700 Subject: [PATCH] After closing for error do not keep alive Raise a StopIteration rather than returning so that the keep-alive loop is terminated. If gunicorn has closed the socket there is no sense in trying to read another request and it may cause spurious EBADF errors to try. --- gunicorn/workers/async.py | 2 +- gunicorn/workers/sync.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/gunicorn/workers/async.py b/gunicorn/workers/async.py index 3bf963c0..1e55789d 100644 --- a/gunicorn/workers/async.py +++ b/gunicorn/workers/async.py @@ -113,7 +113,7 @@ class AsyncWorker(base.Worker): sock.close() except socket.error: pass - return + raise StopIteration() raise finally: try: diff --git a/gunicorn/workers/sync.py b/gunicorn/workers/sync.py index 347b6a28..b57f28b9 100644 --- a/gunicorn/workers/sync.py +++ b/gunicorn/workers/sync.py @@ -152,8 +152,7 @@ class SyncWorker(base.Worker): client.close() except socket.error: pass - - return + raise StopIteration() # Only send back traceback in HTTP in debug mode. self.handle_error(req, client, addr, e) return