File locking

Barry A. Warsaw bwarsaw at cnri.reston.va.us
Tue Jun 1 10:34:38 EDT 1999


>>>>> "AMK" == A M Kuchling <amk1 at erols.com> writes:

    AMK> What is the correct solution for doing file locking in Python
    AMK> programs?

You might want to look at Mailman's flock.py module.  The doc string
says:

    Portable (?) file locking with timeouts.  
    This code should work with all versions of NFS.
    The algorithm was suggested by the GNU/Linux open() man page.  Make
    sure no malicious people have access to link() to the lock file.

It's also been banged on quite a bit, although I'll make no guarantees 
that it's bug free.  It's probably pretty close tho'.

-Barry




More information about the Python-list mailing list