Package pulp :: Package client :: Module lock :: Class LockFile
[hide private]
[frames] | no frames]

Class LockFile

source code

File based locking.

Instance Methods [hide private]
 
__init__(self, path) source code
 
open(self)
Open the lock file.
source code
int
getpid(self)
Get the process id.
source code
 
setpid(self, pid=os.getpid())
Write our procecss id and flush.
source code
int
mypid(self)
Get the current process id.
source code
bool
valid(self)
Get whether the pid in the file is valid.
source code
 
delete(self)
Delete the lock file.
source code
 
close(self)
Close the file and release the file lock.
source code
bool
notcreated(self)
Get if file not created.
source code
 
__del__(self)
cleanup
source code
Instance Variables [hide private]
  fp
The file pointer to the lock file.
str path
The absolute path to the lock file.
int pid
current process id.
Method Details [hide private]

__init__(self, path)
(Constructor)

source code 
Parameters:
  • path (str) - The absolute path to the lock file.

open(self)

source code 

Open the lock file. Created in not exists. Opened with file locking.

getpid(self)

source code 

Get the process id.

Returns: int
The pid in the lock file, else the current pid.

setpid(self, pid=os.getpid())

source code 

Write our procecss id and flush.

Parameters:
  • pid (int) - The process ID.

mypid(self)

source code 

Get the current process id.

Returns: int
This process id.

valid(self)

source code 

Get whether the pid in the file is valid.

Returns: bool
True if valid.

close(self)

source code 

Close the file and release the file lock. Reset pid & fp to (None).

notcreated(self)

source code 

Get if file not created.

Returns: bool
True if file not created.