Classes | Functions | Variables
mycroft.lock Namespace Reference

Classes

class  Lock
 
class  Signal
 

Functions

def __call__ (self, signame, sf)
 
def __del__ (self)
 
def __init__ (self, sig_value, func)
 
def __init__ (self, service)
 
def create (self)
 
def delete (self, args)
 
def exists (self)
 
def set_handlers (self)
 
def touch (self)
 

Variables

 __handlers
 
 __pid
 
 __previous_func
 
 __sig_value
 
 __user_func
 
string DIRECTORY = '/tmp/mycroft'
 
string FILE = '/{}.pid'
 
 path
 

Function Documentation

def mycroft.lock.__call__ (   self,
  signame,
  sf 
)
Allows the instance of this class to be called as a function.
When called it runs the user supplied signal handler than
checks to see if there is a previously defined handler.  If
there is a previously defined handler call it.

Definition at line 61 of file scripts/mycroft/lock/__init__.py.

def mycroft.lock.__del__ (   self)
Class destructor.  Called during garbage collection.
Resets the signal handler to the previous function.

Definition at line 73 of file scripts/mycroft/lock/__init__.py.

def mycroft.lock.__init__ (   self,
  sig_value,
  func 
)
Capture and replace a signal handler with a user supplied function.
The user supplied function is always called first then the previous
handler, if it exists, will be called.  It is possible to chain several
signal handlers together by creating multiply instances of objects of
this class, providing a  different user functions for each instance.  All
provided user functions will be called in LIFO order.
Create an instance of the signal handler class.

sig_value:  The ID value of the signal to be captured.
func:  User supplied function that will act as the new signal handler.

Definition at line 43 of file scripts/mycroft/lock/__init__.py.

def mycroft.lock.__init__ (   self,
  service 
)
Builds the instance of this object.  Holds the lock until the
object is garbage collected.

service: Text string.  The name of the service application
to be locked (ie: skills, voice)

Definition at line 106 of file scripts/mycroft/lock/__init__.py.

def mycroft.lock.create (   self)
Checks to see if a lock file for this service already exists,
if so have it killed.  In either case write the process ID of
the current service process to to the existing or newly created
lock file in /tmp/mycroft/

Definition at line 164 of file scripts/mycroft/lock/__init__.py.

def mycroft.lock.delete (   self,
  args 
)
If the PID lock file contains the PID of this process delete it.

*args: Ignored.  Required as this fuction is called as a signel
handler.

Definition at line 177 of file scripts/mycroft/lock/__init__.py.

def mycroft.lock.exists (   self)
Check to see if the PID lock file currently exists.  If it does
than send a SIGTERM signal to the process defined by the value
in the lock file.  Catch the keyboard interrupt exception to
prevent propagation if stopped by use of Ctrl-C.

Definition at line 134 of file scripts/mycroft/lock/__init__.py.

def mycroft.lock.set_handlers (   self)
Trap both SIGINT and SIGTERM to gracefully clean up PID files

Definition at line 122 of file scripts/mycroft/lock/__init__.py.

def mycroft.lock.touch (   self)
If needed, create the '/tmp/mycroft' directory than open the
lock file for writting and store the current process ID (PID)
as text.

Definition at line 151 of file scripts/mycroft/lock/__init__.py.

Variable Documentation

mycroft.lock.__handlers
private

Definition at line 126 of file scripts/mycroft/lock/__init__.py.

mycroft.lock.__pid
private

Definition at line 115 of file scripts/mycroft/lock/__init__.py.

mycroft.lock.__previous_func
private

Definition at line 53 of file scripts/mycroft/lock/__init__.py.

mycroft.lock.__sig_value
private

Definition at line 51 of file scripts/mycroft/lock/__init__.py.

mycroft.lock.__user_func
private

Definition at line 52 of file scripts/mycroft/lock/__init__.py.

string mycroft.lock.DIRECTORY = '/tmp/mycroft'
Create and maintains the PID lock file for this application process.
The PID lock file is located in /tmp/mycroft/*.pid.  If another process
of the same type is started, this class will 'attempt' to stop the
previously running process and then change the process ID in the lock file.

Definition at line 101 of file scripts/mycroft/lock/__init__.py.

string mycroft.lock.FILE = '/{}.pid'

Definition at line 102 of file scripts/mycroft/lock/__init__.py.

mycroft.lock.path

Definition at line 116 of file scripts/mycroft/lock/__init__.py.



mycroft_ros
Author(s):
autogenerated on Mon Apr 26 2021 02:35:40