On May 4, 2010, at 5:37 PM, pyt...@bdurham.com wrote: > Is there a way to exclusively lock a file to prevent other processes > from reading it while we have it open?
> My environment is Python 2.6.4 (32-bit) under Windows, but I'm looking > for a cross-platform solution if that's possible. Some Unix systems support mandatory locking; Linux used to, but the option appears to have been removed (and was seldom enabled). On Unix systems which support mandatory locking, it is enabled for a particular file by setting the setgid bit on a file which lacks group-execute permission. This causes fcntl() locks to be mandatory, i.e. they cause read()/write() operations to block rather than merely preventing conflicting locks from being obtained. But in general, you can't rely upon mandatory locking being available. -- http://mail.python.org/mailman/listinfo/python-list