Inter-process locking

Piet van Oostrum piet at vanoostrum.org
Sun Oct 13 08:46:42 EDT 2013


Jason Friedman <jsf80238 at gmail.com> writes:

> The lockfile solution seems to be working, thank you.

There is one caveat, however. If a process that has the lock crashes without releasing the lock, the lock file will stay around and prevent other processes to acquire it. Then you will have to manually remove it. I generally prefer a solution where the pid of the locking process is written to the lock file, so that other processes trying to acquire the lock can find out if the process is still around and remove the lock file if not. I have seen such solutions on Unix systems. But I am not sure if this can be done in a platform independent way without the risk of race conditions. Maybe I have to find out.
-- 
Piet van Oostrum <piet at vanoostrum.org>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]



More information about the Python-list mailing list