Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: cms/bin/test_server.py

Issue 29327611: Issue 3056 - [cms] Enable threading for the test server (Closed)
Patch Set: Use daemon threads Created Sept. 15, 2015, 3:22 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cms/bin/test_server.py
===================================================================
--- a/cms/bin/test_server.py
+++ b/cms/bin/test_server.py
@@ -123,7 +123,10 @@
sys.exit("Usage: %s [source_dir]" % sys.argv[0])
try:
- from werkzeug.serving import run_simple
+ from werkzeug.serving import ThreadedWSGIServer, run_simple
+
+ ThreadedWSGIServer.daemon_threads = True
+
def run(*args, **kwargs):
# The werkzeug logger must be configured before the
# root logger. Also we must prevent it from propagating
@@ -134,9 +137,14 @@
logger.setLevel(logging.INFO)
logger.addHandler(logging.StreamHandler())
- run_simple(*args, **kwargs)
+ run_simple(threaded=True, *args, **kwargs)
except ImportError:
- from wsgiref.simple_server import make_server
+ from SocketServer import ThreadingMixIn
+ from wsgiref.simple_server import WSGIServer, make_server
+
+ class ThreadedWSGIServer(ThreadingMixIn, WSGIServer):
+ daemon_threads = True
+
def run(host, port, app, **kwargs):
def wrapper(environ, start_response):
try:
@@ -145,7 +153,7 @@
return show_error(start_response, "500 Internal Server Error",
uri=environ.get("PATH_INFO"), error=e)
- server = make_server(host, port, wrapper)
+ server = make_server(host, port, wrapper, ThreadedWSGIServer)
print " * Running on http://%s:%i/" % server.server_address
server.serve_forever()
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld