"Permission denied" errors removing test directories on Windows.

Mark Hammond mhammond at skippinet.com.au
Thu Jun 26 05:32:57 BST 2008


When running the tests on Windows, its not uncommon to see the message:

| Permission denied: unable to remove testing dir tmpa-x-xxxx

and many test directories get left behind.  We all know files that are
in-use can't be removed on Windows - broadly, I see 3 reasons why this will
be true:

* due to exceptions/stack/etc, a "real" Python reference still exists to the
file object.
* Cyclic garbage still refers to an open file. 
* Some other process has the file open.  Eg, its conceivable a virus scanner
or text indexer is running.

I performed some experiments to try and narrow down the last 2 on my
machine.  In summary:

* The unmodified test suite fails to remove 46 directories
* Adding a 'gc.collect()' directly before the osutils.rmtree in
_rmtree_temp_dir in bzrlib/tests/__init__ reduces this number to 35
* Addng code that has a short 'sleep-then-retry' loop has no effect (ie,
everytime the retry loop was entered it still failed to remove the
directory) 

So - while this information doesn't help us get even 1/2 way to actually
solving the problem, I thought the info may be of interest and probably
worth adding to the test suite as it is *some* improvement.

Also, while this problem remains, it may make sense for the bzr test suite
on Windows to create its own sub-directory under %TEMP% which is the parent
of all other temp directories.  Any thoughts on that?

Cheers,

Mark




More information about the bazaar mailing list