Author: justi9
Date: 2007-10-12 19:54:47 -0400 (Fri, 12 Oct 2007)
New Revision: 1035
Modified:
mgmt/cumin/bin/cumin-test
mgmt/cumin/python/wooly/server.py
Log:
Improves cumin-test a little.
Modified: mgmt/cumin/bin/cumin-test
===================================================================
--- mgmt/cumin/bin/cumin-test 2007-10-12 22:50:16 UTC (rev 1034)
+++ mgmt/cumin/bin/cumin-test 2007-10-12 23:54:47 UTC (rev 1035)
@@ -19,6 +19,14 @@
return args
+def main(port, debug=True):
+ server = CuminServer(port)
+
+ if debug:
+ server.enable_debug()
+
+ server.run()
+
if __name__ == "__main__":
args = load_args(sys.argv)
@@ -27,11 +35,14 @@
if "profile" in args:
import profile, pstats
+ stats_file = "/tmp/cumin-test-stats"
+
try:
- profile.run("CuminServer().run()", "cumin-test-stats")
+ code = "main(%i, %r)" % (port, False)
+ profile.run(code, stats_file)
raise KeyboardInterrupt()
except KeyboardInterrupt:
- stats = pstats.Stats("cumin-test-stats")
+ stats = pstats.Stats(stats_file)
stats.sort_stats("cumulative").print_stats(15)
stats.sort_stats("time").print_stats(15)
@@ -41,4 +52,7 @@
#stats.print_callers("interpolate")
#stats.print_callees("interpolate")
else:
- CuminServer(port).run()
+ try:
+ main(port)
+ except KeyboardInterrupt:
+ pass
Modified: mgmt/cumin/python/wooly/server.py
===================================================================
--- mgmt/cumin/python/wooly/server.py 2007-10-12 22:50:16 UTC (rev 1034)
+++ mgmt/cumin/python/wooly/server.py 2007-10-12 23:54:47 UTC (rev 1035)
@@ -11,6 +11,9 @@
self.app = app
self.port = port
+ def enable_debug(self):
+ self.app.enable_debug()
+
def run(self):
server = HTTPServer(("", self.port), self.RequestHandler)
@@ -20,10 +23,7 @@
print "Cumin server started on port %s" % (self.port)
- try:
- server.serve_forever()
- except KeyboardInterrupt:
- pass
+ server.serve_forever()
class RequestHandler(BaseHTTPRequestHandler):
http_date = "%a, %d %b %Y %H:%M:%S %Z"
Show replies by date