The problem shows up when the application starts. It tries to read the file but 
the lock mechanism times out because the file is still around after the last 
time the application ran.

It's a wxPython program. The code to unlink the .lock files is run in the 
wxApp.OnInit method (before any code to open these resources) and in the 
wxApp.OnExit method. I know both of these methods are being called.

The locking mechanism I am using can be found at 
http://www.evanfosmark.com/2009/01/cross-platform-file-locking-support-in-python/

The clearing code is:

import os
import fnmatch
files = fnmatch.filter(os.listdir(self.Options.DataDir), "*.lock")
for f in files:
    os.unlink(os.path.abspath(os.path.join(self.Options.DataDir, f)))

The Options object has a property called DataDir.

MMM...

Now that I sit down to test abso-frikkin'-lutely that this code does what I 
want it to do, it appears not to do this at all. The files list I build doesn't 
work and returns an empty list. I may have found a workaround using glob.

Now my face is red. 
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to