SOLVED: Can os.remove followed by os.path.isfile disagree?



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

.



Relevant Pages

  • Re: Can os.remove followed by os.path.isfile disagree?
    ... (Windows 2003, Python 2.3) ... os.remove succeeds but the file doesn't actually disappear until the last open ...
    (comp.lang.python)
  • IDLE wont start in Python 2.5 for Windows
    ... I have Python 2.5 and Windows XP SP2. ... for about a second, then disappear. ...
    (comp.lang.python)
  • Re: pygame and python 2.5
    ... I committed to Python because it's a great language. ... modules on the Windows platform without having a copy of Visual Studio ... developing a math library based on GMPY to use ... obsolete compiler that's not even available. ...
    (comp.lang.python)
  • Re: Please test Phatch on Windows (was Re: ANN: Phatch = PHoto bATCH processor and renamer based on
    ... You'll be happy to hear that it appears to work on Vista, though I blush to admit I actually have a Python running on that platform. ... to port the code of Phatch fully to Windows as there were many issues. ... Common - Copies the most common pixel value ...
    (comp.lang.python)
  • ANN: wxPython 2.6.2.1
    ... There have been many enhancements ... wxPython is a GUI toolkit for the Python programming language. ... Currently supported platforms are 32-bit Microsoft Windows, ...
    (comp.lang.python.announce)