better logging on http parse errors

NoMoreData now inherits StopIteration and the StopIteration clause in
the workers logs the reason at debug level.
This commit is contained in:
Randall Leeds 2011-11-07 14:56:59 -08:00
parent c6f949b56b
commit b955407003
3 changed files with 5 additions and 5 deletions

View File

@ -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):

View File

@ -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.")

View File

@ -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.")