Package ganeti :: Module utils :: Class SignalHandler
[hide private]
[frames] | no frames]

Class SignalHandler

source code


Generic signal handler class.

It automatically restores the original handler when deconstructed or when Reset is called. You can either pass your own handler function in or query the called attribute to detect whether the signal was sent.

Instance Methods [hide private]
 
__init__(self, signum, handler_fn=None, wakeup=None)
Constructs a new SignalHandler instance.
source code
 
__del__(self) source code
 
Reset(self)
Restore previous handler.
source code
 
Clear(self)
Unsets the called flag.
source code
 
_HandleSignal(self, signum, frame)
Actual signal handling function.
source code

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

Instance Variables [hide private]
boolean called
tracks whether any of the signals have been raised
list signum
the signals we handle
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, signum, handler_fn=None, wakeup=None)
(Constructor)

source code 

Constructs a new SignalHandler instance.

Parameters:
  • signum (int or list of ints) - Single signal number or set of signal numbers
  • handler_fn (callable) - Signal handling function
Overrides: object.__init__

Reset(self)

source code 

Restore previous handler.

This will reset all the signals to their previous handlers.

Clear(self)

source code 

Unsets the called flag.

This function can be used in case a signal may arrive several times.