cherrypy.subscribe or cherrypy.on_start or cherrypy.on_stop
February 29, 2008 § Leave a comment
Sometimes, on your web application, there are other processes that happen independently from typical HTTP requests.
The type of such processes can be:
- daemon / cron.
- setup / deployment script.
If such processes are not registered to cherrypy, cherrypy might not be able to auto-reload properly when server-side codes changed. In general it is nice to have those processes starting/stopping properly relative to the web server (cherrypy in this case).
In cherrypy 3.1, processes like those can be registered via callback using cherrypy.subscribe function. See below:
- engine.subscribe(‘start’, callback).
- engine.subscribe(‘stop’, callback).
- engine.subscribe(‘start_thread’, callback).
- engine.subscribe(‘stop_thread’, callback).
Above functions in cherrypy 3.0 are: