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


Groups > comp.lang.python > #31738

Re: locking files on Linux

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.unit0.net!feeder1.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.84.MISMATCH!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <andrea.crotti.0@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.011
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'nicely': 0.07; '(without': 0.09; 'prevents': 0.09; 'subject:files': 0.09; 'cc:addr:python- list': 0.10; "'w'": 0.16; 'benjamin': 0.16; 'blocks': 0.16; 'released.': 0.16; 'truncates': 0.16; 'received:209.85.214.174': 0.21; 'cc:2**0': 0.23; 'seems': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'checking': 0.27; 'prevent': 0.27; 'message-id:@mail.gmail.com': 0.27; "i'm": 0.29; 'mode': 0.30; 'file': 0.32; 'problem': 0.33; 'received:google.com': 0.34; 'thanks': 0.34; 'fail': 0.35; 'open': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'should': 0.36; 'does': 0.37; 'being': 0.37; 'quite': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'received:209.85.214': 0.39; 'header:Received:5': 0.40; 'here': 0.65; 'oscar': 0.84; 'instantly': 0.93
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:to :cc:content-type; bh=hGc09ftdNRA43WOH81xw8H5/yPm835lzWuoMUEBzPW0=; b=ImdaODDLsk6lQQ/fC8xwANldco1ieWquoBJ2YxrtNCPh6vMeEWyhujyDIbT1WY+zM0 2ijLV0812ILcXdgNFYFe6CHAf1fUHSQ+N8QRLINlELTmBn+hEGiLWrBlJBuBv89o8ne4 wfw4J5unMzsc8WzflYla9AOjuWCtmvtpLMf62cU/2l27ICB27XIWWJj7TFySJHVHc1bE vId+l3Obwx4nLQa7StdOoF+cjcC6MJLAwWexzPNte+qXnqmWhthulcKO/cy8K/5VsZ/P eEU7tiW3wcWKpJfADpFDS+he2PqvxJJ6KnlMnWZ4u0DzAIr+aM7oPg4nctLJtF8pqSVi 0j0w==
MIME-Version 1.0
In-Reply-To <CAHVvXxSNsxjLD9X74-7Awe7uFxKU5cYeryqsRm3J-HxPFQ=AwA@mail.gmail.com>
References <mailman.2430.1350566044.27098.python-list@python.org> <k5p03u$3t8$2@reader1.panix.com> <mailman.2431.1350567869.27098.python-list@python.org> <k5p1rg$et4$1@reader1.panix.com> <CAF_E5Jb9javdypCvPpVGkq+zPLmt-autD=bu+Z-uDrghhGneog@mail.gmail.com> <CAHVvXxTCE8d_RoKgiT2S1XgMpUNPpd5gMHbCunicjEOOfU1GnQ@mail.gmail.com> <CAF_E5Jbf3FagsPaMcQ11pKiPAzPSA2G-cS7r8Jemr84MaoKRyg@mail.gmail.com> <CAHVvXxSNsxjLD9X74-7Awe7uFxKU5cYeryqsRm3J-HxPFQ=AwA@mail.gmail.com>
Date Fri, 19 Oct 2012 13:15:25 +0100
Subject Re: locking files on Linux
From andrea crotti <andrea.crotti.0@gmail.com>
To Oscar Benjamin <oscar.j.benjamin@gmail.com>
Content-Type text/plain; charset=ISO-8859-1
Cc python-list@python.org
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 <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2505.1350648928.27098.python-list@python.org> (permalink)
Lines 16
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1350648928 news.xs4all.nl 6930 [2001:888:2000:d::a6]:37300
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:31738

Show key headers only | View raw


2012/10/18 Oscar Benjamin <oscar.j.benjamin@gmail.com>:
>
> The lock is cooperative. It does not prevent the file from being
> opened or overwritten. It only prevents any other process from
> obtaining the lock. Here you open the file with mode 'w' which
> truncates the file instantly (without checking for the lock).
>
>
> Oscar


Very good thanks now I understood, actually my problem was in the
assumption that it should fail when the lock is already taken, but by
default lockf just blocks until the lock is released.

It seems to work quite nicely so I'm going to use this..

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


Thread

locking files on Linux andrea crotti <andrea.crotti.0@gmail.com> - 2012-10-18 14:14 +0100
  Re: locking files on Linux Grant Edwards <invalid@invalid.invalid> - 2012-10-18 13:27 +0000
    Re: locking files on Linux andrea crotti <andrea.crotti.0@gmail.com> - 2012-10-18 14:44 +0100
      Re: locking files on Linux Grant Edwards <invalid@invalid.invalid> - 2012-10-18 13:57 +0000
        Re: locking files on Linux andrea crotti <andrea.crotti.0@gmail.com> - 2012-10-18 15:49 +0100
        Re: locking files on Linux Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2012-10-18 16:04 +0100
        Re: locking files on Linux andrea crotti <andrea.crotti.0@gmail.com> - 2012-10-18 16:08 +0100
        Re: locking files on Linux Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2012-10-18 16:31 +0100
        Re: locking files on Linux andrea crotti <andrea.crotti.0@gmail.com> - 2012-10-19 13:15 +0100
      Re: locking files on Linux Nobody <nobody@nowhere.com> - 2012-10-19 15:36 +0100
    Re: locking files on Linux Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2012-10-18 14:58 +0100

csiph-web