[Python-Dev] Does Python need a file locking module (slightly higher level)?
Barry Warsaw
barry at python.org
Mon Oct 22 15:37:03 CEST 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Oct 22, 2007, at 8:15 AM, skip at pobox.com wrote:
> I'm always daunted by the prospect of trying to implement file
> locking.
> This just came up again in SpamBayes where we have never protected our
> pickle files from corruption when multiple processes access them
> simultaneously. The presence of networked file systems and
> platform-independent locks make it a nasty little problem. Maybe
> I'm just
> showing my age. Does fcntl.flock work over NFS and SMB and on
> Windows? If
> this is still as much of a mess as I remember, should Python provide a
> simple file locking module in the standard distribution?
If you want something like this, you might start by looking at
Mailman's LockFile.py. It has a particular set of semantics (such as
lock breaking) that you might not be interested in, but it is, or can
be, mostly de-Mailmanized for use as a general library module. In
the particular use case it is designed for, it's been quite stable
for many years. Essentially it provides an NFS-safe lock file
implementation.
- -Barry
http://codebrowse.launchpad.net/~mailman-coders/mailman/3.0/annotate/
barry%40python.org-20071011032203-w1j8qrmtlpkrvay4?
file_id=mailmanlockfile.py-20070507165525-0o0kligrooe34vyc-172
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
iQCVAwUBRxyngHEjvBPtnXfVAQKPOwP+JhuIC2LiOsHDPLtAft4bSMaYC1qfVJqG
q6SXFc8yJauE9zKttPcn9kkbgONj3RYbDJ9qW4aVA7fJfHEiRDbW8omp/e7rTELl
fIonBDnIk5XEo5bL/JslMudgInOa6BY7yGzCKjaRRy19wSmOZ8ptroXfOvLgqF+e
n7WVkh82sD8=
=aFzw
-----END PGP SIGNATURE-----
More information about the Python-Dev
mailing list