File locking

John Nagle nagle at animats.com
Tue Mar 13 01:29:39 CET 2007


Marc 'BlackJack' Rintsch wrote:
> In <1173722982.696539.24360 at 64g2000cwx.googlegroups.com>, Dr. Who wrote:
> 
> 
>>Please let me know if I'm missing something since they seem like
>>normal file operations that I would hope Python would abstract away.
> 
> 
> I don't think of them as "normal" operations.  They are "extra" stuff that
> is not only dependent on the operating system but also on the file system
> in use.

    It's a UNIX legacy problem.  UNIX historically was very weak
at interprocess communication and locking, and while today, most
UNIX-like systems have some kind of add-on for those functions,
they were never really standardized.

    But see

http://www.thinkspot.net/scripts/posixmutexfile.py
http://www.thinkspot.net/scripts/mutexfile.py
http://www.thinkspot.net/scripts/winmutexfile.py

for an attempt to deal with this probl;em in a portable way.
The code is somewhat dated, but it's on the right track.

				John Nagle



More information about the Python-list mailing list