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


Groups > comp.lang.python > #56762

Re: Inter-process locking

Path csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <jsf80238@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.177
X-Spam-Level *
X-Spam-Evidence '*H*': 0.65; '*S*': 0.01; 'detect': 0.07; 'deploy': 0.09; 'pgp': 0.09; 'subject:process': 0.09; 'runs': 0.10; 'cc:addr :python-list': 0.11; 'wrote:': 0.18; 'seems': 0.21; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'second': 0.26; 'van': 0.27; 'header:In-Reply-To:1': 0.27; 'generally': 0.29; 'url:code': 0.29; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'writes:': 0.31; 'anyone': 0.31; 'file': 0.32; 'probably': 0.32; 'run': 0.32; 'quite': 0.32; 'url:python': 0.33; 'fri,': 0.33; 'mac': 0.33; "i'd": 0.34; 'could': 0.34; 'received:google.com': 0.35; 'url:listinfo': 0.36; 'url:org': 0.36; 'two': 0.37; 'level': 0.37; 'thank': 0.38; 'conditions.': 0.38; 'jason': 0.38; 'skip:[ 10': 0.38; 'pm,': 0.38; 'launch': 0.39; 'users': 0.40; 'url:mail': 0.40; 'tell': 0.60; 'success': 0.61; 'first': 0.61; 'you.': 0.62; 'times': 0.62; 'kind': 0.63; 'day.': 0.63; 'happen': 0.63; 'url:p': 0.64; 'user,': 0.69; 'repeat.': 0.84; 'working,': 0.84; 'to:none': 0.92; 'wanting': 0.93; 'race': 0.95; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=XPoC3bkEy99Et9QKN0Z1CKXghiRPvn1YtjNtMEysXrc=; b=bnL6wykPLRK0jEH5DBl7mqLMpQoO1nd8aCthxnDQoK8e7X0OWmBQamMzFfFC9xNJXh N9u6hlxiJK4Wv+4Xss91h/hLncAnEDbGgGmi891jQDpAtWOjU1hm8S6giQ8VhXLVTjC1 JMbvxJ2SXal9nUxRD0uWQIxhZO5IHAsaliQWCg45QyitGmGUxM0ea6ojn3oCls6mdOoA 3hus6B3j7f3KgT3/tuhBE6FBR3Dwf9Yjo60/FWDCHffw7u2uAV6IzBwVfAKC+detX7TD 1FUGBgN+lVlyG21R06BAtKUJlfhk9JHacus0Z9Y6zPHPHVHzDKn9MGKAvT9eCNXQ+SjB K7WQ==
MIME-Version 1.0
X-Received by 10.50.126.2 with SMTP id mu2mr8345249igb.57.1381639367085; Sat, 12 Oct 2013 21:42:47 -0700 (PDT)
In-Reply-To <m2vc13rup4.fsf@cochabamba.vanoostrum.org>
References <mailman.1025.1381541497.18130.python-list@python.org> <m2vc13rup4.fsf@cochabamba.vanoostrum.org>
Date Sat, 12 Oct 2013 22:42:47 -0600
Subject Re: Inter-process locking
From Jason Friedman <jsf80238@gmail.com>
Cc python-list <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1048.1381639375.18130.python-list@python.org> (permalink)
Lines 34
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1381639375 news.xs4all.nl 15883 [2001:888:2000:d::a6]:48577
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:56762

Show key headers only | View raw


The lockfile solution seems to be working, thank you.

On Fri, Oct 11, 2013 at 10:15 PM, Piet van Oostrum <piet@vanoostrum.org> wrote:
> Jason Friedman <jsf80238@gmail.com> writes:
>
>> I have a 3rd-party process that runs for about a minute and supports
>> only a single execution at a time.
>>
>> $ deploy
>>
>> If I want to launch a second process I have to wait until the first
>> finishes.  Having two users wanting to run at the same time might
>> happen a few times a day.  But, these users will not have the
>> skills/patience to check whether someone else is currently running.
>> I'd like my program to be able to detect that "deploy" is already
>> running, tell the user, wait a minute, try again, repeat.
>>
>> I do not know whether anyone has had success with
>> http://pythonhosted.org/lockfile/lockfile.html.
>
> It seems to work on Mac OS X.
>
>> I supose I could use http://code.google.com/p/psutil/ to check for a
>> process with a particular name.
>
> That will quite probably give you race conditions.
>
> File locking is generally the best solution for this kind of problems, unless you can make use of OS level semaphores.
> --
> Piet van Oostrum <piet@vanoostrum.org>
> WWW: http://pietvanoostrum.com/
> PGP key: [8DAE142BE17999C4]
> --
> https://mail.python.org/mailman/listinfo/python-list

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