Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4a.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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python,': 0.02; 'error:': 0.07; 'modify': 0.07; 'weeks.': 0.07; 'app,': 0.09; 'method:': 0.09; 'weeks,': 0.09; 'thread': 0.14; '24]': 0.16; 'files:': 0.16; 'mechanism.': 0.16; 'threads.': 0.16; 'prevent': 0.16; 'wrote:': 0.18; 'file,': 0.19; 'written': 0.21; '31,': 0.24; 'bytes': 0.24; 'file.': 0.24; 'header:In-Reply-To:1': 0.27; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'file': 0.32; 'open': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'should': 0.36; 'application': 0.37; 'too': 0.37; 'christian': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'here': 0.66; 'between': 0.67; 'mar': 0.68; '3-4': 0.68; '2015': 0.84; 'datas': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=IUG5HWShE4SEw5qVib5Pn6A8vnFQuSEkxL9cj5rv44s=; b=t5zFKdF8wl1IcV1mEGHzaVEK2KDmMuhnQPIRiQDdFTgJXeYriHsc0RXQmCElb+HN4I PX96fOOZ7YyeWNmf/tV3VOLCyIDQQEHxnvb0v7Yj5y22vLIb+i4GXcfjO3hI1jY9zVcq KXV6wEcqLQaOhO2DqrW34OvVL6ycSFi8t0CiUCrESg7Vkjnul93SgiBL2lEHbCxivRDt 3YoG4Y4VYyfmuBnxmSGSAx76L2Iu7ybkdEZn9TzhGbN2G0KPaxIb69KldiKTm0a+tp/u T56Qoe+mIieMTv0SreRFIrl92LyJAQa0eRx4sJcU1VRNKZQ9VNXyxLaw1GDTOK0hByv9 fa5A== X-Received: by 10.66.100.138 with SMTP id ey10mr70067729pab.142.1427829471094; Tue, 31 Mar 2015 12:17:51 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: From: Ian Kelly Date: Tue, 31 Mar 2015 13:17:10 -0600 Subject: Re: Lockfile hanling To: Python Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.19 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: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1427829474 news.xs4all.nl 2864 [2001:888:2000:d::a6]:43505 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:88399 On Tue, Mar 31, 2015 at 12:58 PM, Christian Gollwitzer wr= ote: > Am 31.03.15 um 16:50 schrieb Ervin Heged=C3=BCs: >> >> 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.