[Python-Dev] Tests failing on Windows with TESTFN
On Sat, Jul 28, 2018 at 8:41 AM Tim Golden <mail at timgolden.me.uk> wrote:
> 1) Why are these errors occurring? ie are we dodging a root cause issue
The root cause is how Windows handles file deletions. When a file is
removed, it is not immediately removed from the directory, instead, it
is simply marked for deletion. Only once all open handles to the file
are closed, is it removed from the directory. The most common cause
of additional open handles to a file is a antivirus scanner.
> 2) Isn't this what test.support.unlink is there to solve?
Yes. If test.support.unlink doesn't succeed in removing the file, a
RuntimeWarning will be emitted.
> For (1) I'm putting together a test run using code which I originally
> wrote for https://bugs.python.org/issue7443 to force the issues out into
> the open.
These intermittent errors are tough as it is really just a matter of
timing. The faster the disk and the more loaded the CPU, the more
often these can occur, however.
> For (2), yes: test.support.unlink is supposed to solve that. But it's
> either not doing enough retries etc. or it's missing a trick.
If you are not seeing the RuntimeWarnings, then something else is amiss.