diff --git a/gunicorn/http/errors.py b/gunicorn/http/errors.py index dd9a602b..beafa05c 100644 --- a/gunicorn/http/errors.py +++ b/gunicorn/http/errors.py @@ -6,7 +6,7 @@ class ParseException(Exception): pass -class NoMoreData(ParseException): +class NoMoreData(ParseException, StopIteration): def __init__(self, buf=None): self.buf = buf def __str__(self): diff --git a/gunicorn/workers/async.py b/gunicorn/workers/async.py index b1898e99..6f31e314 100644 --- a/gunicorn/workers/async.py +++ b/gunicorn/workers/async.py @@ -36,8 +36,8 @@ class AsyncWorker(base.Worker): if not req: break self.handle_request(req, client, addr) - except StopIteration: - pass + except StopIteration, e: + self.log.debug("Closing connection. %s", e) except socket.error, e: if e[0] not in (errno.EPIPE, errno.ECONNRESET): self.log.exception("Socket error processing request.") diff --git a/gunicorn/workers/sync.py b/gunicorn/workers/sync.py index b89830ca..d619c365 100644 --- a/gunicorn/workers/sync.py +++ b/gunicorn/workers/sync.py @@ -69,8 +69,8 @@ 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 StopIteration, e: + self.log.debug("Closing connection. %s", e) except socket.error, e: if e[0] != errno.EPIPE: self.log.exception("Error processing request.")