Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #56769

Re: Inter-process locking

From Piet van Oostrum <piet@vanoostrum.org>
Newsgroups comp.lang.python
Subject Re: Inter-process locking
Date 2013-10-13 08:46 -0400
Message-ID <m261t1qqx9.fsf@cochabamba.vanoostrum.org> (permalink)
References <mailman.1025.1381541497.18130.python-list@python.org> <m2vc13rup4.fsf@cochabamba.vanoostrum.org> <mailman.1048.1381639375.18130.python-list@python.org>

Show all headers | View raw


Jason Friedman <jsf80238@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@vanoostrum.org>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Inter-process locking Jason Friedman <jsf80238@gmail.com> - 2013-10-11 17:44 -0600
  Re: Inter-process locking Piet van Oostrum <piet@vanoostrum.org> - 2013-10-12 00:15 -0400
    Re: Inter-process locking Jason Friedman <jsf80238@gmail.com> - 2013-10-12 22:42 -0600
      Re: Inter-process locking Piet van Oostrum <piet@vanoostrum.org> - 2013-10-13 08:46 -0400
        Re: Inter-process locking Jason Friedman <jsf80238@gmail.com> - 2013-10-18 20:08 -0600

csiph-web