| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 1 # coding: utf-8 | 1 # coding: utf-8 |
| 2 | 2 |
| 3 # This file is part of the Adblock Plus web scripts, | 3 # This file is part of the Adblock Plus web scripts, |
| 4 # Copyright (C) 2006-2015 Eyeo GmbH | 4 # Copyright (C) 2006-2015 Eyeo GmbH |
| 5 # | 5 # |
| 6 # Adblock Plus is free software: you can redistribute it and/or modify | 6 # Adblock Plus is free software: you can redistribute it and/or modify |
| 7 # it under the terms of the GNU General Public License version 3 as | 7 # it under the terms of the GNU General Public License version 3 as |
| 8 # published by the Free Software Foundation. | 8 # published by the Free Software Foundation. |
| 9 # | 9 # |
| 10 # Adblock Plus is distributed in the hope that it will be useful, | 10 # Adblock Plus is distributed in the hope that it will be useful, |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 def run(*args, **kwargs): | 127 def run(*args, **kwargs): |
| 128 # The werkzeug logger must be configured before the | 128 # The werkzeug logger must be configured before the |
| 129 # root logger. Also we must prevent it from propagating | 129 # root logger. Also we must prevent it from propagating |
| 130 # messages, otherwise messages are logged twice. | 130 # messages, otherwise messages are logged twice. |
| 131 import logging | 131 import logging |
| 132 logger = logging.getLogger("werkzeug") | 132 logger = logging.getLogger("werkzeug") |
| 133 logger.propagate = False | 133 logger.propagate = False |
| 134 logger.setLevel(logging.INFO) | 134 logger.setLevel(logging.INFO) |
| 135 logger.addHandler(logging.StreamHandler()) | 135 logger.addHandler(logging.StreamHandler()) |
| 136 | 136 |
| 137 run_simple(*args, **kwargs) | 137 run_simple(threaded=True, *args, **kwargs) |
| 138 except ImportError: | 138 except ImportError: |
| 139 from wsgiref.simple_server import make_server | 139 from SocketServer import ThreadingMixIn |
| 140 from wsgiref.simple_server import WSGIServer, make_server | |
| 141 | |
| 142 class ThreadedWSGIServer(ThreadingMixIn, WSGIServer): | |
|
kzar
2015/09/15 08:41:41
Perhaps we should set the daemon_threads attribute
Sebastian Noack
2015/09/15 15:23:12
I agree that it would be preferable to have all th
| |
| 143 pass | |
| 144 | |
| 140 def run(host, port, app, **kwargs): | 145 def run(host, port, app, **kwargs): |
| 141 def wrapper(environ, start_response): | 146 def wrapper(environ, start_response): |
| 142 try: | 147 try: |
| 143 return app(environ, start_response) | 148 return app(environ, start_response) |
| 144 except Exception, e: | 149 except Exception, e: |
| 145 return show_error(start_response, "500 Internal Server Error", | 150 return show_error(start_response, "500 Internal Server Error", |
| 146 uri=environ.get("PATH_INFO"), error=e) | 151 uri=environ.get("PATH_INFO"), error=e) |
| 147 | 152 |
| 148 server = make_server(host, port, wrapper) | 153 server = make_server(host, port, wrapper, ThreadedWSGIServer) |
| 149 print " * Running on http://%s:%i/" % server.server_address | 154 print " * Running on http://%s:%i/" % server.server_address |
| 150 server.serve_forever() | 155 server.serve_forever() |
| 151 | 156 |
| 152 run("localhost", 5000, handler, use_reloader=True, use_debugger=True) | 157 run("localhost", 5000, handler, use_reloader=True, use_debugger=True) |
| OLD | NEW |