Package ganeti :: Module daemon :: Class Mainloop
[hide private]
[frames] | no frames]

Class Mainloop

source code


Generic mainloop for daemons

Instance Methods [hide private]
 
__init__(self)
Constructs a new Mainloop instance.
source code
 
Run(self, shutdown_wait_fn=None, signal_handlers=None)
Runs the mainloop.
source code
 
_CallSignalWaiters(self, signum)
Calls all signal waiters for a certain signal.
source code
 
RegisterSignal(self, owner)
Registers a receiver for signal notifications
source code

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

Class Variables [hide private]
  _SHUTDOWN_TIMEOUT_PRIORITY = -(sys.maxint-1)
Instance Variables [hide private]
  scheduler
A sched.scheduler object, which can be used to register timed events
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 

Constructs a new Mainloop instance.

Overrides: object.__init__

Run(self, shutdown_wait_fn=None, signal_handlers=None)

source code 

Runs the mainloop.

Parameters:
  • shutdown_wait_fn (callable) - Function to check whether loop can be terminated; important: function must be idempotent and must return either None for shutting down or a timeout for another call
  • signal_handlers (dict) - signal->utils.SignalHandler passed by decorator
Decorators:
  • @utils.SignalHandled([signal.SIGCHLD])
  • @utils.SignalHandled([signal.SIGTERM])
  • @utils.SignalHandled([signal.SIGINT])

_CallSignalWaiters(self, signum)

source code 

Calls all signal waiters for a certain signal.

Parameters:
  • signum (int) - Signal number

RegisterSignal(self, owner)

source code 

Registers a receiver for signal notifications

The receiver must support a "OnSignal(self, signum)" function.

Parameters:
  • owner (instance) - Receiver