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: 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: References: Date: Fri, 19 Oct 2012 13:15:25 +0100 Subject: Re: locking files on Linux From: andrea crotti To: Oscar Benjamin 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 2012/10/18 Oscar Benjamin : > > 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..