Skip to content

Commit

Permalink
better logging on http parse errors
Browse files Browse the repository at this point in the history
NoMoreData now inherits StopIteration and the StopIteration clause in
the workers logs the reason at debug level.
  • Loading branch information
tilgovi committed Nov 7, 2011
1 parent c6f949b commit b955407
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion gunicorn/http/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions gunicorn/workers/async.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def handle(self, client, addr):
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.")
Expand Down
4 changes: 2 additions & 2 deletions gunicorn/workers/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def handle(self, client, addr):
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.")
Expand Down

0 comments on commit b955407

Please sign in to comment.