9 statistics = pdm.perf.staticdir()
10 statistics["req"] = pdm.perf.valueattr(reqstat)
11 requests = pdm.perf.eventobj()
13 class reqstart(pdm.perf.startevent):
14 def __init__(self, env):
15 super(reqstart, self).__init__()
16 self.method = env.get("REQUEST_METHOD")
17 self.uri = env.get("REQUEST_URI")
18 self.host = env.get("HTTP_HOST")
19 self.script_uri = env.get("SCRIPT_NAME")
20 self.script_path = env.get("SCRIPT_FILENAME")
21 self.pathinfo = env.get("PATH_INFO")
22 self.querystring = env.get("QUERY_STRING")
23 self.remoteaddr = env.get("REMOTE_ADDR")
24 self.remoteport = env.get("REMOTE_PORT")
25 self.scheme = env.get("wsgi.url_scheme")
27 class reqfinish(pdm.perf.finishevent):
28 def __init__(self, start, aborted, status):
29 super(reqfinish, self).__init__(start, aborted)
32 class request(object):
33 def __init__(self, env):
36 self.startev = reqstart(env)
37 requests.notify(self.startev)
39 def response(self, resp):
42 def finish(self, aborted):
46 if len(self.resp) > 0:
55 reqstat[key] = reqstat.setdefault(key, 0) + 1
57 requests.notify(reqfinish(self.startev, aborted, status))
62 def __exit__(self, *excinfo):
63 self.finish(bool(excinfo[0]))