Package cherrypy :: Package process :: Module plugins :: Class ThreadManager
[hide private]
[frames] | no frames]

Class ThreadManager

source code

  object --+    
           |    
SimplePlugin --+
               |
              ThreadManager

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.

Instance Methods [hide private]
 
__init__(self, bus)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
acquire_thread(self)
Run 'start_thread' listeners for the current thread.
source code
 
release_thread(self)
Release the current thread and run 'stop_thread' listeners.
source code
 
stop(self)
Release all threads and run all 'stop_thread' listeners.
source code
 
graceful(self)
Release all threads and run all 'stop_thread' listeners.
source code

Inherited from SimplePlugin: subscribe, unsubscribe

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, bus)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

acquire_thread(self)

source code 

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.