From e12e77765a0f463a82aa36ee5731f17880c8b942 Mon Sep 17 00:00:00 2001 From: "Paul J. Davis" Date: Wed, 7 Jul 2010 20:21:53 -0400 Subject: [PATCH] Ignore StopIteration in HTTP parser. We're specifically throwing the stop iteration to signal that a connection was closed before data appeared (which is necessary for the Keep-Alive processing). While a bit confusing for sync workers as there's no Keep-Alive, it is an expected behavior. Closes #65 --- gunicorn/workers/async.py | 2 +- gunicorn/workers/sync.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/gunicorn/workers/async.py b/gunicorn/workers/async.py index 5d6ac585..6d26dcac 100644 --- a/gunicorn/workers/async.py +++ b/gunicorn/workers/async.py @@ -45,7 +45,7 @@ class AsyncWorker(base.Worker): if e[0] == errno.ECONNRESET: self.log.warn("Ignoring connection reset") else: - self.log.warn("Ignoring EPIPE") + self.log.debug("Ignoring EPIPE") except Exception, e: self.log.exception("General error processing request.") try: diff --git a/gunicorn/workers/sync.py b/gunicorn/workers/sync.py index 6fda3b45..a12e9ae8 100644 --- a/gunicorn/workers/sync.py +++ b/gunicorn/workers/sync.py @@ -73,11 +73,13 @@ class SyncWorker(base.Worker): parser = http.RequestParser(client) req = parser.next() self.handle_request(req, client, addr) + except StopIteration: + self.log.debug("Ignored premature client disconnection.") except socket.error, e: if e[0] != errno.EPIPE: self.log.exception("Error processing request.") else: - self.log.warn("Ignoring EPIPE") + self.log.debug("Ignoring EPIPE") except Exception, e: self.log.exception("Error processing request.") try: