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


Groups > comp.lang.python > #31738

Re: locking files on Linux

References (3 earlier) <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 2012-10-19 13:15 +0100
Subject Re: locking files on Linux
From andrea crotti <andrea.crotti.0@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.2505.1350648928.27098.python-list@python.org> (permalink)

Show all headers | 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