Commit fa0327cd authored by Tim Peters's avatar Tim Peters

CommonSetupTearDown.tearDown(): Ack, this is a mess. Before 2.3, there's

not enough stuff in the Windows Python to wait for spawned servers to shut
down.  Spawned servers inherit descriptors for open files from the
spawning process, and because Windows won't let you delete a file that's
still open, the client can't get rid of temp .zec files until the server(s)
disappear(s).  There's no good fix for this before 2.3 on Windows.  For
now, try deleting the temp files repeatedly, sleeping between failures,
but don't wait forever.  If a temp file can't be deleted in the end, raise
the appropriate exception.  This should be rare.  It's important not to
keep going blindly, as I saw one case earlier today where a test passed
by accident due to picking up a .zec file left behind by a previous test
run.
parent de8eb286
...@@ -109,8 +109,24 @@ class CommonSetupTearDown(StorageTestBase): ...@@ -109,8 +109,24 @@ class CommonSetupTearDown(StorageTestBase):
for c in self.caches: for c in self.caches:
for i in 0, 1: for i in 0, 1:
path = "c1-%s-%d.zec" % (c, i) path = "c1-%s-%d.zec" % (c, i)
# On Windows before 2.3, we don't have a way to wait for
# the spawned server(s) to close, and they inherited
# file descriptors for our open files. So long as those
# processes are alive, we can't delete the files. Try
# a few times then give up.
need_to_delete = 0
if os.path.exists(path): if os.path.exists(path):
os.unlink(path) need_to_delete = 1
for dummy in range(5):
try:
os.unlink(path)
except:
time.sleep(0.5)
else:
need_to_delete = 0
break
if need_to_delete:
os.unlink(path) # sometimes this is just gonna fail
self.__super_tearDown() self.__super_tearDown()
def _newAddr(self): def _newAddr(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment