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


Groups > comp.lang.python > #88399

Re: Lockfile hanling

References <mailman.374.1427813384.10327.python-list@python.org> <mfeqm7$r6e$1@dont-email.me>
From Ian Kelly <ian.g.kelly@gmail.com>
Date 2015-03-31 13:17 -0600
Subject Re: Lockfile hanling
Newsgroups comp.lang.python
Message-ID <mailman.385.1427829474.10327.python-list@python.org> (permalink)

Show all headers | View raw


On Tue, Mar 31, 2015 at 12:58 PM, Christian Gollwitzer <auriocus@gmx.de> wrote:
> Am 31.03.15 um 16:50 schrieb Ervin Hegedüs:
>>
>> there is an app, written in Python, which stores few bytes of
>> datas in a single file. The application uses threads. Every
>> thread can modify the file, but only one at a time. I'm using a
>> lock file to prevent the multiple access.
>>
>> Here is the lock method:
>>
>> [...]
>> This works as well for me - about 3-4 weeks. After some weeks, I
>> got this error:
>>
>> OSError: [Errno 24] Too many open files: '/var/spool/myapp/queue.lock'
>>
>
> Can you try if fcntl.flock() does what you want? Should be better than
> inventing your own locking mechanism.

flock locks are per-process; they won't help for synchronizing access
between competing threads in the same process.

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


Thread

Lockfile hanling Ervin Hegedüs <airween@gmail.com> - 2015-03-31 16:50 +0200
  Re: Lockfile hanling Christian Gollwitzer <auriocus@gmx.de> - 2015-03-31 20:58 +0200
    Re: Lockfile hanling Ian Kelly <ian.g.kelly@gmail.com> - 2015-03-31 13:17 -0600
      Re: Lockfile hanling Christian Gollwitzer <auriocus@gmx.de> - 2015-03-31 21:59 +0200
        Re: Lockfile hanling Ian Kelly <ian.g.kelly@gmail.com> - 2015-03-31 14:12 -0600
        Re: Lockfile hanling Sturla Molden <sturla.molden@gmail.com> - 2015-04-01 23:51 +0000

csiph-web