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:

  • engine.on_start_engine_list.append(callback).
  • engine.on_stop_engine_list.append(callback).
  • engine.on_start_thread_list.append(callback).
  • engine.on_stop_thread_list.append(callback).

References:

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

What’s this?

You are currently reading cherrypy.subscribe or cherrypy.on_start or cherrypy.on_stop at RAPD.

meta

%d bloggers like this: