Lockfile hanling

Christian Gollwitzer auriocus at gmx.de
Tue Mar 31 14:58:04 EDT 2015


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.

	Christian



More information about the Python-list mailing list