On Tue, Mar 31, 2015 at 12:58 PM, Christian Gollwitzer <aurio...@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. -- https://mail.python.org/mailman/listinfo/python-list