fcntl problems

Miles semanticist at gmail.com
Fri Aug 31 02:23:13 EDT 2007


Sorry, that last quote-only reply was accidental. :)

On 8/30/07, mhearne808 wrote:
> I've been doing some experiments, and here are some specific examples
> to try.

[snipped examples]

> From these last two experiments I can only conclude that file locking
> isn't doing a durned thing.
>
> What's going on?

File locking isn't doing a durned thing in those cases because you're
only obtaining the lock from a single process.

> According to my Python Cookbook:
> "Exclusive lock: This denies all _other_ processes both read and write
> access to the file."

This is only for mandatory locking; POSIX flock is advisory locking,
which states: "Only one process may hold an exclusive lock for a given
file at a given time."  Advisory locks don't have any effect on
processes that don't use locks.  Mandatory locks are kernel enforced,
but non-POSIX and not available in Mac OS X.

-Miles



More information about the Python-list mailing list