Deleting files on a shared server

Tim Golden mail at timgolden.me.uk
Fri Oct 7 03:45:32 EDT 2011


On 07/10/2011 02:14, Josh English wrote:
> This is a follow-up to some questions I posted a month or two ago. I
> have two programs running on various Windows XP boxes, sharing
> several resource files on a Windows 2003 server. It's a mapped drive
> on the workstations to a shared folder.
>
> I am using a locking utility that works by creating ".lock" files in
> the shared folder and deleting those files when the program is done
> with them.
>
> To delete the files, I am using os.unlink.
>
> One lock file refuses to disappear, even though I have code at both
> application startup and shutdown (on the OnInit and OnExit methods to
> the wxPython Application object) that hunts down .lock files and
> deletes them.

Assuming that your code paths succeed and that the unlink actually
happens, it is possible for files to continue to exist after they
have been successfully deleted. This happens if another process
has opened them with share-delete mode; typically this will be
a virus checker or a process like the TortoiseSVN cache (or its
counterparts for other VCS). The file won't actually disappear
until the last handle on it is released.

TJG



More information about the Python-list mailing list