| Trees | Index | Help |
|
|---|
|
|
object --+
|
Lock --+
|
LockFile
A file like object with an exclusive lock, whilst it is open.
The lock is provided by the Lock class, which creates a directory with the same name as the file (plus a trailing underscore), to indicate that the file is locked.
This is simple and cross platform, with some limitations :
- Unusual process termination could result in the directory being left.
- The process acquiring the lock must have permission to create a directory in the same location as the file.
- It only locks the file against other processes that attempt to acquire a lock using LockFile or Lock.
|
|||
|
__init__(self,
filename,
mode='r',
bufsize=-1,
timeout=5,
step=0.1,
force=True)
Create a file like object that is locked (using the Lock class) until it is closed. |
|||
|
close(self,
ignore=True)
close the file and release the lock. |
|||
|
__getattr__(self,
name)
delegate appropriate method/attribute calls to the file. |
|||
|
__setattr__(self,
name,
value)
Only allow attribute setting that don't clash with the file. |
|||
|
__del__(self)
Auto unlock (and close file) when object is deleted. |
|||
|
Inherited from |
|||
| Inherited from Lock | |||
|---|---|---|---|
|
_mungedname(self)
Override this in a subclass if you want to change the way Lock creates the directory name. |
|||
|
lock(self,
force=True)
Lock the file for access by creating a directory of the same name (plus a trailing underscore). |
|||
|
unlock(self,
ignore=True)
Release the lock. |
|||
|
|||
|
Inherited from |
|||
|
|||
Create a file like object that is locked (using the Lock class) until it is closed. The file is only locked against another process that attempts to acquire a lock using Lock (or LockFile). The lock is released automatically when the file is closed. The filename, mode and bufsize arguments have the same meaning as for the built in function open. The timeout and step arguments have the same meaning as for a Lock object. The force argument has the same meaning as for the Lock.lock method. A LockFile object has all the normal file methods and attributes.
|
close the file and release the lock. ignore has the same meaning as for Lock.unlock |
|
|
|
| Trees | Index | Help |
|
|---|
| Generated by Epydoc 3.0alpha2 on Sat Apr 29 11:03:38 2006 | http://epydoc.sf.net |