diff options
-rw-r--r-- | cherrypy/__init__.py | 2 | ||||
-rw-r--r-- | cherrypy/_cpserver.py | 18 | ||||
-rw-r--r-- | cherrypy/lib/covercp.py | 4 | ||||
-rw-r--r-- | cherrypy/lib/profiler.py | 4 | ||||
-rw-r--r-- | cherrypy/test/benchmark.py | 2 | ||||
-rw-r--r-- | cherrypy/test/helper.py | 4 | ||||
-rw-r--r-- | cherrypy/test/test_session_concurrency.py | 2 | ||||
-rw-r--r-- | cherrypy/test/test_states.py | 10 | ||||
-rw-r--r-- | cherrypy/test/test_states_demo.py | 2 | ||||
-rw-r--r-- | cherrypy/tutorial/bonus-sqlobject.py | 4 | ||||
-rw-r--r-- | cherrypy/tutorial/tut02_expose_methods.py | 2 | ||||
-rw-r--r-- | cherrypy/tutorial/tut03_get_and_post.py | 2 | ||||
-rw-r--r-- | cherrypy/tutorial/tut04_complex_site.py | 2 | ||||
-rw-r--r-- | cherrypy/tutorial/tut05_derived_objects.py | 2 | ||||
-rw-r--r-- | cherrypy/tutorial/tut06_default_method.py | 2 | ||||
-rw-r--r-- | cherrypy/tutorial/tut07_sessions.py | 2 | ||||
-rw-r--r-- | cherrypy/tutorial/tut08_generators_and_yield.py | 2 | ||||
-rw-r--r-- | cherrypy/tutorial/tut09_files.py | 2 | ||||
-rw-r--r-- | cherrypy/tutorial/tut10_http_errors.py | 2 |
19 files changed, 34 insertions, 36 deletions
diff --git a/cherrypy/__init__.py b/cherrypy/__init__.py index 39a64bfa..46e57df6 100644 --- a/cherrypy/__init__.py +++ b/cherrypy/__init__.py @@ -20,7 +20,7 @@ server = _cpserver.Server() def quickstart(root, script_name="", conf=None): """Mount the given app, start the engine and builtin server, then block.""" tree.mount(root, script_name, conf) - server.start() + server.quickstart() engine.start() try: diff --git a/cherrypy/_cpserver.py b/cherrypy/_cpserver.py index 273263c0..2d5f466a 100644 --- a/cherrypy/_cpserver.py +++ b/cherrypy/_cpserver.py @@ -15,12 +15,16 @@ class Server(object): self.httpservers = {} self.interrupt = None - def start(self, server=None): - """Main function. MUST be called from the main thread.""" - self.interrupt = None + def quickstart(self, server=None): + """Main function for quick starts. MUST be called from the main thread. + + This function works like CherryPy 2's server.start(). It loads and + starts an httpserver based on the given server object, if any, and + config entries. + """ httpserver, bind_addr = self.httpserver_from_config(server) self.httpservers[httpserver] = bind_addr - self._start_http(httpserver) + self.start() def httpserver_from_config(self, httpserver=None): """Return a (httpserver, bind_addr) pair based on config settings.""" @@ -42,8 +46,9 @@ class Server(object): else: return httpserver, conf('server.socket_file') - def start_all(self): + def start(self): """Start all registered HTTP servers.""" + self.interrupt = None for httpserver in self.httpservers: self._start_http(httpserver) @@ -120,8 +125,7 @@ class Server(object): def restart(self): """Restart the HTTP server.""" self.stop() - self.interrupt = None - self.start_all() + self.start() def check_port(host, port): diff --git a/cherrypy/lib/covercp.py b/cherrypy/lib/covercp.py index 1ef53fb3..7441aaaa 100644 --- a/cherrypy/lib/covercp.py +++ b/cherrypy/lib/covercp.py @@ -349,13 +349,11 @@ def serve(path=localFile, port=8080): coverage.cache_default = path import cherrypy - cherrypy.tree.mount(CoverStats()) cherrypy.config.update({'server.socket_port': port, 'server.thread_pool': 10, 'environment': "production", }) - cherrypy.server.start() - cherrypy.engine.start() + cherrypy.quickstart(CoverStats()) if __name__ == "__main__": serve(*tuple(sys.argv[1:])) diff --git a/cherrypy/lib/profiler.py b/cherrypy/lib/profiler.py index e3b9d066..7afbf74d 100644 --- a/cherrypy/lib/profiler.py +++ b/cherrypy/lib/profiler.py @@ -170,13 +170,11 @@ class make_app: def serve(path=None, port=8080): import cherrypy - cherrypy.tree.mount(Profiler(path)) cherrypy.config.update({'server.socket_port': int(port), 'server.thread_pool': 10, 'environment': "production", }) - cherrypy.server.start() - cherrypy.engine.start() + cherrypy.quickstart(Profiler(path)) if __name__ == "__main__": diff --git a/cherrypy/test/benchmark.py b/cherrypy/test/benchmark.py index fcfa664e..5800f85c 100644 --- a/cherrypy/test/benchmark.py +++ b/cherrypy/test/benchmark.py @@ -401,6 +401,6 @@ if __name__ == '__main__': cherrypy.server.request_class = NullRequest cherrypy.server.response_class = NullResponse - cherrypy.server.start() + cherrypy.server.quickstart() # This will block cherrypy.engine.start_with_callback(run) diff --git a/cherrypy/test/helper.py b/cherrypy/test/helper.py index 918bf280..65616c97 100644 --- a/cherrypy/test/helper.py +++ b/cherrypy/test/helper.py @@ -97,7 +97,7 @@ def run_test_suite(moduleNames, server, conf): """ cherrypy.config.reset() setConfig(conf) - cherrypy.server.start(server) + cherrypy.server.quickstart(server) cherrypy.engine.start_with_callback(_run_test_suite_thread, args=(moduleNames, conf)) @@ -147,7 +147,7 @@ def testmain(conf=None): conf = {} setConfig(conf) try: - cherrypy.server.start() + cherrypy.server.quickstart() cherrypy.engine.start_with_callback(_test_main_thread) except KeyboardInterrupt: cherrypy.server.stop() diff --git a/cherrypy/test/test_session_concurrency.py b/cherrypy/test/test_session_concurrency.py index 6902932d..425c9830 100644 --- a/cherrypy/test/test_session_concurrency.py +++ b/cherrypy/test/test_session_concurrency.py @@ -79,7 +79,7 @@ def run_client(cookie, request_count, data_dict, index): data_dict[index] = int(data) # Start server -cherrypy.server.start() +cherrypy.server.quickstart() thread.start_new_thread(cherrypy.engine.start, ()) # Start client diff --git a/cherrypy/test/test_states.py b/cherrypy/test/test_states.py index 77e90ca2..c44116d7 100644 --- a/cherrypy/test/test_states.py +++ b/cherrypy/test/test_states.py @@ -67,7 +67,7 @@ class ServerStateTests(helper.CPWebCase): self.assertEqual(len(db_connection.threads), 0) # Test server start - cherrypy.server.start(self.server_class) + cherrypy.server.quickstart(self.server_class) cherrypy.engine.start(blocking=False) self.assertEqual(cherrypy.engine.state, 1) @@ -110,7 +110,7 @@ class ServerStateTests(helper.CPWebCase): cherrypy.server.stop() def test_1_Restart(self): - cherrypy.server.start(self.server_class) + cherrypy.server.start() cherrypy.engine.start(blocking=False) # The db_connection should be running now @@ -152,8 +152,8 @@ class ServerStateTests(helper.CPWebCase): # Raise a keyboard interrupt in the HTTP server's main thread. # We must start the server in this, the main thread cherrypy.engine.start(blocking=False) - cherrypy.server.start(self.server_class) - cherrypy.server.httpservers.values()[0].interrupt = KeyboardInterrupt + cherrypy.server.start() + cherrypy.server.httpservers.keys()[0].interrupt = KeyboardInterrupt while cherrypy.engine.state != 0: time.sleep(0.1) @@ -166,7 +166,7 @@ class ServerStateTests(helper.CPWebCase): # This should raise a BadStatusLine error, since the worker # thread will just die without writing a response. cherrypy.engine.start(blocking=False) - cherrypy.server.start(self.server_class) + cherrypy.server.start() from httplib import BadStatusLine try: diff --git a/cherrypy/test/test_states_demo.py b/cherrypy/test/test_states_demo.py index 65681165..d8f949fc 100644 --- a/cherrypy/test/test_states_demo.py +++ b/cherrypy/test/test_states_demo.py @@ -27,4 +27,4 @@ if __name__ == '__main__': "environment": "development", }) cherrypy.quickstart(Root()) -
\ No newline at end of file +
\ No newline at end of file diff --git a/cherrypy/tutorial/bonus-sqlobject.py b/cherrypy/tutorial/bonus-sqlobject.py index fc5e756e..0c903611 100644 --- a/cherrypy/tutorial/bonus-sqlobject.py +++ b/cherrypy/tutorial/bonus-sqlobject.py @@ -165,6 +165,4 @@ class ContactManager: print "If you're running this application for the first time, please go to http://localhost:8080/reset once in order to create the database!" -cherrypy.tree.mount(ContactManager()) -cherrypy.server.start() -cherrypy.engine.start() +cherrypy.quickstart(ContactManager()) diff --git a/cherrypy/tutorial/tut02_expose_methods.py b/cherrypy/tutorial/tut02_expose_methods.py index 3a47630d..abde830f 100644 --- a/cherrypy/tutorial/tut02_expose_methods.py +++ b/cherrypy/tutorial/tut02_expose_methods.py @@ -24,6 +24,6 @@ cherrypy.tree.mount(HelloWorld()) if __name__ == '__main__': import os.path cherrypy.config.update(os.path.join(os.path.dirname(__file__), 'tutorial.conf')) - cherrypy.server.start() + cherrypy.server.quickstart() cherrypy.engine.start() diff --git a/cherrypy/tutorial/tut03_get_and_post.py b/cherrypy/tutorial/tut03_get_and_post.py index 57b6cafc..43f4afb3 100644 --- a/cherrypy/tutorial/tut03_get_and_post.py +++ b/cherrypy/tutorial/tut03_get_and_post.py @@ -46,5 +46,5 @@ cherrypy.tree.mount(WelcomePage()) if __name__ == '__main__': import os.path cherrypy.config.update(os.path.join(os.path.dirname(__file__), 'tutorial.conf')) - cherrypy.server.start() + cherrypy.server.quickstart() cherrypy.engine.start() diff --git a/cherrypy/tutorial/tut04_complex_site.py b/cherrypy/tutorial/tut04_complex_site.py index 05fcee8c..42467ca5 100644 --- a/cherrypy/tutorial/tut04_complex_site.py +++ b/cherrypy/tutorial/tut04_complex_site.py @@ -88,6 +88,6 @@ cherrypy.tree.mount(root) if __name__ == '__main__': import os.path cherrypy.config.update(os.path.join(os.path.dirname(__file__), 'tutorial.conf')) - cherrypy.server.start() + cherrypy.server.quickstart() cherrypy.engine.start() diff --git a/cherrypy/tutorial/tut05_derived_objects.py b/cherrypy/tutorial/tut05_derived_objects.py index 9d6f703f..f922e03c 100644 --- a/cherrypy/tutorial/tut05_derived_objects.py +++ b/cherrypy/tutorial/tut05_derived_objects.py @@ -75,6 +75,6 @@ cherrypy.tree.mount(HomePage()) if __name__ == '__main__': import os.path cherrypy.config.update(os.path.join(os.path.dirname(__file__), 'tutorial.conf')) - cherrypy.server.start() + cherrypy.server.quickstart() cherrypy.engine.start() diff --git a/cherrypy/tutorial/tut06_default_method.py b/cherrypy/tutorial/tut06_default_method.py index 63c63e2f..b8b5afdb 100644 --- a/cherrypy/tutorial/tut06_default_method.py +++ b/cherrypy/tutorial/tut06_default_method.py @@ -56,6 +56,6 @@ cherrypy.tree.mount(UsersPage()) if __name__ == '__main__': import os.path cherrypy.config.update(os.path.join(os.path.dirname(__file__), 'tutorial.conf')) - cherrypy.server.start() + cherrypy.server.quickstart() cherrypy.engine.start() diff --git a/cherrypy/tutorial/tut07_sessions.py b/cherrypy/tutorial/tut07_sessions.py index 5272c380..e7bb9772 100644 --- a/cherrypy/tutorial/tut07_sessions.py +++ b/cherrypy/tutorial/tut07_sessions.py @@ -36,6 +36,6 @@ cherrypy.tree.mount(HitCounter()) if __name__ == '__main__': import os.path cherrypy.config.update(os.path.join(os.path.dirname(__file__), 'tutorial.conf')) - cherrypy.server.start() + cherrypy.server.quickstart() cherrypy.engine.start() diff --git a/cherrypy/tutorial/tut08_generators_and_yield.py b/cherrypy/tutorial/tut08_generators_and_yield.py index 4d6750ad..396a1122 100644 --- a/cherrypy/tutorial/tut08_generators_and_yield.py +++ b/cherrypy/tutorial/tut08_generators_and_yield.py @@ -38,6 +38,6 @@ cherrypy.tree.mount(GeneratorDemo()) if __name__ == '__main__': import os.path cherrypy.config.update(os.path.join(os.path.dirname(__file__), 'tutorial.conf')) - cherrypy.server.start() + cherrypy.server.quickstart() cherrypy.engine.start() diff --git a/cherrypy/tutorial/tut09_files.py b/cherrypy/tutorial/tut09_files.py index 97e69eed..bfa7b568 100644 --- a/cherrypy/tutorial/tut09_files.py +++ b/cherrypy/tutorial/tut09_files.py @@ -97,5 +97,5 @@ if __name__ == '__main__': import os.path # Start the CherryPy server. cherrypy.config.update(os.path.join(os.path.dirname(__file__), 'tutorial.conf')) - cherrypy.server.start() + cherrypy.server.quickstart() cherrypy.engine.start() diff --git a/cherrypy/tutorial/tut10_http_errors.py b/cherrypy/tutorial/tut10_http_errors.py index 207e8cd0..e57ec396 100644 --- a/cherrypy/tutorial/tut10_http_errors.py +++ b/cherrypy/tutorial/tut10_http_errors.py @@ -74,5 +74,5 @@ cherrypy.tree.mount(HTTPErrorDemo()) if __name__ == '__main__': # Start the CherryPy server. cherrypy.config.update(os.path.join(os.path.dirname(__file__), 'tutorial.conf')) - cherrypy.server.start() + cherrypy.server.quickstart() cherrypy.engine.start() |