mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
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:
parent
c6f949b56b
commit
b955407003
@ -6,7 +6,7 @@
|
|||||||
class ParseException(Exception):
|
class ParseException(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class NoMoreData(ParseException):
|
class NoMoreData(ParseException, StopIteration):
|
||||||
def __init__(self, buf=None):
|
def __init__(self, buf=None):
|
||||||
self.buf = buf
|
self.buf = buf
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
|||||||
@ -36,8 +36,8 @@ class AsyncWorker(base.Worker):
|
|||||||
if not req:
|
if not req:
|
||||||
break
|
break
|
||||||
self.handle_request(req, client, addr)
|
self.handle_request(req, client, addr)
|
||||||
except StopIteration:
|
except StopIteration, e:
|
||||||
pass
|
self.log.debug("Closing connection. %s", e)
|
||||||
except socket.error, e:
|
except socket.error, e:
|
||||||
if e[0] not in (errno.EPIPE, errno.ECONNRESET):
|
if e[0] not in (errno.EPIPE, errno.ECONNRESET):
|
||||||
self.log.exception("Socket error processing request.")
|
self.log.exception("Socket error processing request.")
|
||||||
|
|||||||
@ -69,8 +69,8 @@ class SyncWorker(base.Worker):
|
|||||||
parser = http.RequestParser(client)
|
parser = http.RequestParser(client)
|
||||||
req = parser.next()
|
req = parser.next()
|
||||||
self.handle_request(req, client, addr)
|
self.handle_request(req, client, addr)
|
||||||
except StopIteration:
|
except StopIteration, e:
|
||||||
self.log.debug("Ignored premature client disconnection.")
|
self.log.debug("Closing connection. %s", e)
|
||||||
except socket.error, e:
|
except socket.error, e:
|
||||||
if e[0] != errno.EPIPE:
|
if e[0] != errno.EPIPE:
|
||||||
self.log.exception("Error processing request.")
|
self.log.exception("Error processing request.")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user