Ugly fix for #321. cherrypy.server could really use some encapsulation now.
1. server.start now MUST be called from the main thread, or restart and interrupts won't work. You can stop and restart CherryPy safely now with the server.stop and server.restart methods. However, stop() only suspends the process; if you want to shut down the CP process, raise SystemExit? or KeyboardInterrupt?. If you need to do so in your own threads, set cherrypy._interrupt to an instance of one of those exceptions.
2. New cherrypy._httpserverclass attribute, so that threads can wait for the HTTP server to truly start.
3. server.start() now defaults serverClass to _missing, so if you were using None to get the WSGIServer, switch to _missing.
4. server has some new methods: start_app_server, start_http_server, stop_http_server, stop_app_server.
5. There's also a new start_with_callback function, so you don't have to code the threading yourself if you want to start the server but run another task in a new thread.
6. test/helper.py doesn't have startServer/stopServer methods anymore. Just call server.start/stop instead.
|