mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
Merge pull request #2336 from elendiastarman/gevent-statsd-fix
Fixed two bugs related to gevent + gunicorn + statsd.
This commit is contained in:
commit
26c22af2e7
@ -98,6 +98,8 @@ class Statsd(Logger):
|
||||
Logger.access(self, resp, req, environ, request_time)
|
||||
duration_in_ms = request_time.seconds * 1000 + float(request_time.microseconds) / 10 ** 3
|
||||
status = resp.status
|
||||
if isinstance(status, bytes):
|
||||
status = status.decode('utf-8')
|
||||
if isinstance(status, str):
|
||||
status = int(status.split(None, 1)[0])
|
||||
self.histogram("gunicorn.request.duration", duration_in_ms)
|
||||
|
||||
@ -166,7 +166,11 @@ class PyWSGIHandler(pywsgi.WSGIHandler):
|
||||
finish = datetime.fromtimestamp(self.time_finish)
|
||||
response_time = finish - start
|
||||
resp_headers = getattr(self, 'response_headers', {})
|
||||
resp = GeventResponse(self.status, resp_headers, self.response_length)
|
||||
|
||||
# Status is expected to be a string but is encoded to bytes in gevent for PY3
|
||||
# Except when it isn't because gevent uses hardcoded strings for network errors.
|
||||
status = self.status.decode() if isinstance(self.status, bytes) else self.status
|
||||
resp = GeventResponse(status, resp_headers, self.response_length)
|
||||
if hasattr(self, 'headers'):
|
||||
req_headers = self.headers.items()
|
||||
else:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user