How to lock files (the easiest/best way)?
Gerhard Fiedler
gelists at gmail.com
Sat Jul 15 18:52:40 EDT 2006
On 2006-07-15 18:52:10, Sybren Stuvel wrote:
> Elmo Mäntynen enlightened us with:
>> Only locally. I want to be able to read/write to a single file from
>> multiple possibly parallel processes. Would 'touch lock' (or
>> something like that) work reliably (this just occured to me)?
>
> I use a lock directory for that, os.mkdir('/var/lock/somedir').
> If you use a file, you need two steps:
> 1) Check whether the lock-file exists
> 2) Create the lock-file
cvsnt for example used to use lock files. Now it uses a lock server: a
server app that just sits there and allows different processes to acquire,
check for and release locks on files. More implementation work, probably,
but more efficient.
Gerhard
More information about the Python-list
mailing list