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.remoteaddr = env.get("REMOTE_ADDR")
20 self.remoteport = env.get("REMOTE_PORT")
22 class reqfinish(pdm.perf.finishevent):
23 def __init__(self, start, aborted, status):
24 super(reqfinish, self).__init__(start, aborted)
27 class request(object):
28 def __init__(self, env):
31 self.startev = reqstart(env)
32 requests.notify(self.startev)
34 def response(self, resp):
37 def finish(self, aborted):
41 if len(self.resp) > 0:
50 reqstat[key] = reqstat.setdefault(key, 0) + 1
52 requests.notify(reqfinish(self.startev, aborted, status))
57 def __exit__(self, *excinfo):
58 self.finish(bool(excinfo[0]))