Lockfile hanling

Ervin Hegedüs airween at gmail.com
Tue Mar 31 11:06:56 EDT 2015


Hi Skip,

thanks for the reply,

On Tue, Mar 31, 2015 at 09:55:57AM -0500, Skip Montanaro wrote:
> On Tue, Mar 31, 2015 at 9:50 AM, Ervin Hegedüs <airween at gmail.com> wrote:
> > After few weeks the process
> > reaches the number if max fd's.
> >
> > How can I prevent or avoid this issue? What's the correct way to
> > handle the lockfile in Python?
> 
> Ervin,
> 
> You need to close the files you open. I don't see that happening in
> your code snippet.

sorry - at the end of the function there is a close() method to a
file, after the thread passes the modifications:

    try:
        os.remove(self.lockfile)
    except:
        syslog.syslog(syslog.LOG_DEBUG, "Sync error: " + str(sys.exc_info()[1]))

And I think, the "(deleted)" info near the filename in proc/PID/fd
means the lockfile had been deleted.

> You might consider the pylockfile module, available
> from PyPI:
> 
> https://pypi.python.org/pypi/lockfile
> 
> (I'm the original author, though others have taken it over.)

sounds good, thanks - what's the minimal version of Python? I've
only 2.5 on that server...


Regards,


a.




More information about the Python-list mailing list