Package cherrypy :: Package process :: Module wspbus :: Class Bus
[hide private]
[frames] | no frames]

Class Bus

source code

object --+
         |
        Bus

Process state-machine and messenger for HTTP site deployment.

All listeners for a given channel are guaranteed to be called even if others at the same channel fail. Each failure is logged, but execution proceeds on to the next listener. The only way to stop all processing from inside a listener is to raise SystemExit and stop the whole server.

Instance Methods [hide private]
 
__init__(self)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
subscribe(self, channel, callback, priority=None)
Add the given callback at the given channel (if not present).
source code
 
unsubscribe(self, channel, callback)
Discard the given callback (if present).
source code
 
publish(self, channel, *args, **kwargs)
Return output of all subscribers for the given channel.
source code
 
_clean_exit(self)
An atexit handler which asserts the Bus is not running.
source code
 
start(self)
Start all services.
source code
 
exit(self)
Stop all services and prepare to exit the process.
source code
 
restart(self)
Restart the process (may close connections).
source code
 
graceful(self)
Advise all services to reload.
source code
 
block(self, interval=0.1)
Wait for the EXITING state, KeyboardInterrupt or SystemExit.
source code
 
wait(self, state, interval=0.1)
Wait for the given state(s).
source code
 
_do_execv(self)
Re-execute the current process.
source code
 
stop(self)
Stop all services.
source code
 
start_with_callback(self, func, args=None, kwargs=None)
Start 'func' in a new thread T, then start self (and return T).
source code
 
log(self, msg='', level=20, traceback=False)
Log the given message.
source code

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

Class Variables [hide private]
  states = _StateEnum()
  state = states.STOPPED
  execv = False
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 

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

Overrides: object.__init__
(inherited documentation)

restart(self)

source code 

Restart the process (may close connections).

This method does not restart the process from the calling thread; instead, it stops the bus and asks the main thread to call execv.

block(self, interval=0.1)

source code 

Wait for the EXITING state, KeyboardInterrupt or SystemExit.

This function is intended to be called only by the main thread. After waiting for the EXITING state, it also waits for all threads to terminate, and then calls os.execv if self.execv is True. This design allows another thread to call bus.restart, yet have the main thread perform the actual execv call (required on some platforms).

_do_execv(self)

source code 

Re-execute the current process.

This must be called from the main thread, because certain platforms (OS X) don't allow execv to be called in a child thread very well.

log(self, msg='', level=20, traceback=False)

source code 

Log the given message. Append the last traceback if requested.