[Lldb-commits] [lldb] r265948 - Retry deletion of temporary files to avoid race conditions on Windows.
Adrian McCarthy via lldb-commits
lldb-commits at lists.llvm.org
Mon Apr 11 08:21:01 PDT 2016
Date: Mon Apr 11 10:21:01 2016
New Revision: 265948
Retry deletion of temporary files to avoid race conditions on Windows.
Differential Revision: http://reviews.llvm.org/D18912
--- lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py Mon Apr 11 10:21:01 2016
@@ -1049,23 +1049,13 @@ class Base(unittest2.TestCase):
# it silently replaces the destination. Ultimately this means that atomic renames are not
# guaranteed to be possible on Windows, but we need this to work anyway, so just remove the
# destination first if it already exists.
# success! (and we don't want log files) delete log files
for log_file in log_files_for_this_test:
- # We've seen consistent unlink failures on Windows, perhaps because the
- # just-created log file is being scanned by anti-virus. Empirically, this
- # sleep-and-retry approach allows tests to succeed much more reliably.
- # Attempts to figure out exactly what process was still holding a file handle
- # have failed because running instrumentation like Process Monitor seems to
- # slow things down enough that the problem becomes much less consistent.
# Config. methods supported through a plugin interface
@@ -1996,4 +1986,17 @@ class TestBase(Base):
def RemoveTempFile(cls, file):
+# On Windows, the first attempt to delete a recently-touched file can fail
+# because of a race with antimalware scanners. This function will detect a
+# failure and retry.
+def remove_file(file, num_retries = 1, sleep_duration = 0.5):
+ for i in range(num_retries+1):
+ return True
+ return False
More information about the lldb-commits