Skip to content
Browse files

fix gevent_pywsgi worker. close #314

access_log arity has changed in 0.14.0. Apply this change to the pywsgi
worker as well.
  • Loading branch information...
1 parent b7b6179 commit d6012fa84b6f86cbd5d4e5010856b0f8da9bd643 @benoitc benoitc committed Mar 16, 2012
Showing with 23 additions and 2 deletions.
  1. +6 −1 gunicorn/glogging.py
  2. +17 −1 gunicorn/workers/ggevent.py
View
7 gunicorn/glogging.py
@@ -175,7 +175,12 @@ def access(self, resp, req, environ, request_time):
}
# add request headers
- atoms.update(dict([("{%s}i" % k.lower(),v) for k, v in req.headers]))
+ if hasattr(req, 'headers'):
+ req_headers = req.headers
+ else:
+ req_headers = req
+
+ atoms.update(dict([("{%s}i" % k.lower(),v) for k, v in req_headers]))
# add response headers
atoms.update(dict([("{%s}o" % k.lower(),v) for k, v in resp.headers]))
View
18 gunicorn/workers/ggevent.py
@@ -96,13 +96,29 @@ def init_process(self):
gevent.core.dns_init()
super(GeventWorker, self).init_process()
+
+class GeventResponse(object):
+
+ status = None
+ headers = None
+ response_length = None
+
+
+ def __init__(self, status, headers, clength):
+ self.status = status
+ self.headers = headers
+ self.response_length = clength
+
class PyWSGIHandler(pywsgi.WSGIHandler):
def log_request(self):
start = datetime.fromtimestamp(self.time_start)
finish = datetime.fromtimestamp(self.time_finish)
response_time = finish - start
- self.server.log.access(self, self.environ, response_time)
+ resp = GeventResponse(self.status, self.response_headers,
+ self.response_length)
+ req_headers = [h.split(":", 1) for h in self.headers.headers]
+ self.server.log.access(resp, req_headers, self.environ, response_time)
def get_environ(self):
env = super(PyWSGIHandler, self).get_environ()

0 comments on commit d6012fa

Please sign in to comment.
Something went wrong with that request. Please try again.