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: 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: References: Date: Sat, 12 Oct 2013 22:42:47 -0600 Subject: Re: Inter-process locking From: Jason Friedman Cc: python-list 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 The lockfile solution seems to be working, thank you. On Fri, Oct 11, 2013 at 10:15 PM, Piet van Oostrum wrote: > Jason Friedman 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 > WWW: http://pietvanoostrum.com/ > PGP key: [8DAE142BE17999C4] > -- > https://mail.python.org/mailman/listinfo/python-list