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 help(type(x)) 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, channel=None)
Poll for the given state(s) at intervals; publish to channel.
source code
 
_do_execv(self)
Re-execute the current process.
source code
 
_set_cloexec(self)
Set the CLOEXEC flag on all open files (except stdin/out/err).
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
  max_cloexec_files = 65536
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) 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.

_set_cloexec(self)

source code 

Set the CLOEXEC flag on all open files (except stdin/out/err).

If self.max_cloexec_files is an integer (the default), then on platforms which support it, it represents the max open files setting for the operating system. This function will be called just before the process is restarted via os.execv() to prevent open files from persisting into the new process.

Set self.max_cloexec_files to 0 to disable this behavior.

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

source code 

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