locking files
Christopher Lee
clee at gnwy100.wuh.wustl.edu
Wed Feb 21 14:42:36 EST 2001
>>>>> "Christopher" == Christopher Lee <clee at gnwy100.wuh.wustl.edu> writes:
>> chmod g+s tmp; chmod g-x tmp python
>>> import fcntl, FCNTL fp = open("tmp", "rw") fd = fp.fileno()
>>> fcntl.lockf(fd, FCNTL.F_LOCK) # secures the lock, prevents
Oops, FCNTL.F_LOCK is wrong here (although when I typed it in the example
worked by coincidence). Looking at the python source of fcntlmodule.c,
it's actually asking for fcntl's LOCK_EX, LOCK_SH, LOCK_UN, or LOCK_NB.
-chris
#ifndef LOCK_SH
#define LOCK_SH 1 /* shared lock */
#define LOCK_EX 2 /* exclusive lock */
#define LOCK_NB 4 /* don't block when locking */
#define LOCK_UN 8 /* unlock */
More information about the Python-list
mailing list