Site services for use with a Web Site Process Bus.
Plugin base class which auto-subscribes methods for known channels.
Bases: cherrypy.process.plugins.SimplePlugin
Manager for HTTP request threads.
If you have control over thread creation and destruction, publish to the ‘acquire_thread’ and ‘release_thread’ channels (for each thread). This will register/unregister the current thread and publish to ‘start_thread’ and ‘stop_thread’ listeners in the bus as needed.
If threads are created and destroyed by code you do not control (e.g., Apache), then, at the beginning of every HTTP request, publish to ‘acquire_thread’ only. You should not publish to ‘release_thread’ in this case, since you do not know whether the thread will be re-used or not. The bus will call ‘stop_thread’ listeners for you when it stops.
Run ‘start_thread’ listeners for the current thread.
If the current thread has already been seen, any ‘start_thread’ listeners will not be run again.
A subclass of threading.Thread whose run() method repeats.
Use this class for most repeating tasks. It uses time.sleep() to wait for each interval, which isn’t very responsive; that is, even if you call self.cancel(), you’ll have to wait until the sleep() call finishes before the thread stops. To compensate, it defaults to being daemonic, which means it won’t delay stopping the whole process.
A responsive subclass of threading._Timer whose run() method repeats.
Use this timer only when you really need a very interruptible timer; this checks its ‘finished’ condition up to 20 times a second, which can results in pretty high CPU usage
Bases: cherrypy.process.plugins.SimplePlugin
WSPBus listener to periodically run a callback in its own thread.
Bases: cherrypy.process.plugins.Monitor
Monitor which re-executes the process when files change.
This plugin restarts the process (via os.execv()) if any of the files it monitors change (or is deleted). By default, the autoreloader monitors all imported modules; you can add to the set by adding to autoreload.files:
cherrypy.engine.autoreload.files.add(myFile)
If there are imported files you do not wish to monitor, you can adjust the match attribute, a regular expression. For example, to stop monitoring cherrypy itself:
cherrypy.engine.autoreload.match = r'^(?!cherrypy).+'
Like all Monitor plugins, the autoreload plugin takes a frequency argument. The default is 1 second; that is, the autoreloader will examine files once each second.