SOLVED: Can os.remove followed by os.path.isfile disagree?
- From: Paul Paterson <ppaterson@xxxxxxxxx>
- Date: Wed, 06 Jun 2007 11:58:41 -0700
On Jun 6, 12:30 pm, "Roger Upole" <rup...@xxxxxxxxxxx> wrote:
ppater...@xxxxxxxxx wrote:
Can os.path.isfile(x) ever return True after os.remove(x) has
successfully completed? (Windows 2003, Python 2.3)
Yes. If another application has opened the file with FILE_SHARE_DELETE,
os.remove succeeds but the file doesn't actually disappear until the last open
handle to it is closed.
Roger,
Thanks - you've hit the nail on the head. This is the final piece of
the puzzle and I've now been able to reproduce the problem!
The cause is ...
- a TSVCache.exe (Tortoise SVN) process is scanning the file with
FILE_SHARE_DELETE access at the moment that the os.remove occurs
- this causes os.remove to return but the file is still there while
the scan completes
- next, os.path.isfile returns True and the app raises an exception
- a short while later the scan is complete and Windows deletes the
file
Thanks to everyone who responded - I didn't expect to be able to get
to the bottom of this so quickly!
Thanks,
Paul
.
- References:
- Can os.remove followed by os.path.isfile disagree?
- From: ppaterson
- Re: Can os.remove followed by os.path.isfile disagree?
- From: Roger Upole
- Can os.remove followed by os.path.isfile disagree?
- Prev by Date: Invalid argument with fcntl.fcntl
- Next by Date: Re: Determinant of Large Matrix
- Previous by thread: Re: Can os.remove followed by os.path.isfile disagree?
- Next by thread: lists - append - unique and sorted
- Index(es):
Relevant Pages
|