Package wtf :: Package opi :: Module daemon :: Class Pidfile
[hide private]
[frames] | no frames]

Class Pidfile

source code

object --+
         |
        Pidfile

PID file representation
Instance Methods [hide private]
 
__init__(self, name)
Initialization
source code
 
__del__(self) source code
 
release(self)
Close the pid file, remove it and release any lock
source code
 
close(self)
Close the pidfile (do not release it)
source code
bool
acquire(self)
Open the pid file and acquire a lock
source code
int
read(self)
Read the pid from the file
source code
 
write(self, pid)
Write a pid into the file
source code
file
_open(self)
Open the pid file
source code
bool
_lock(self)
Try locking the pid file
source code

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

Class Variables [hide private]
int _O_FLAGS = 66
opening flags for the pid file
int _L_FLAGS = 6
locking flags for the pid file
  _fp = None
  _locked = False
Instance Variables [hide private]
str name = None
The name of the pidfile
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, name)
(Constructor)

source code 
Initialization
Parameters:
  • name (str) - The name of the pid file
Overrides: object.__init__

acquire(self)

source code 
Open the pid file and acquire a lock
Returns: bool
Did we acquire the lock?
Raises:

read(self)

source code 
Read the pid from the file
Returns: int
The pid from the file
Raises:

write(self, pid)

source code 
Write a pid into the file
Parameters:
  • pid (int) - The PID to write
Raises:
  • AssertionError - The pid file was not open or not locked
  • PidfileError - I/O error while writing the file

_open(self)

source code 
Open the pid file
Returns: file
The file object
Raises:

_lock(self)

source code 
Try locking the pid file
Returns: bool
Did we get the lock?
Raises:
  • AssertionError - Pidfile is not open
  • PidfileError - Some I/O error occurred while accessing the descriptor