locking files

Joseph Holland King insanc at cc.gatech.edu
Wed Feb 21 09:48:34 EST 2001


Joseph Holland King <insanc at cc.gatech.edu> wrote:

: is there anyway to lock a file so that two different programs cannot access
: the file at the same time. ie, my python module is editting file foo, and
: at the same time user x (or program x) tries to read from it. is there 
: anyway that the python module can prevent x from accessing the file for
: a given amount of time?

to clarify: i am on a unix system, i have tried to use flock however when i
locked the file i was still able to read, write and copy the file, none of 
which i want to happen while the file is locked. while using the flock 
method i was using LOCK_EX. also the third party program is not going to be
controlled, written, or have anything to do with mine. am i just not using
flock properly or is there something else that might do the job? thank you.

-- 
---
Joseph Holland King  | "God whispers to us in our pleasures, speaks in our
                     |  conscience, but shouts in our pains: it is His
                     |  megaphone to rouse a deaf world." C. S. Lewis



More information about the Python-list mailing list