Lockfile hanling

Skip Montanaro skip.montanaro at gmail.com
Tue Mar 31 11:19:27 EDT 2015


> 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]))

Hmmm... Still not seeing os.close(fl)...

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

os.remove() will remove the lockfile name from the directory. It
doesn't automatically close the file.

>> You might consider the pylockfile module...

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

When I was still maintaining it, it worked with 2.5, and I distributed
a patch you could apply to get it to work with 2.4. I'm not sure if
the current maintainers have changed that. You'd have to look. If
worse comes to worst, I believe 0.9.1 (the last version I released)
should still work with 2.5.

Skip



More information about the Python-list mailing list