[Zope3-checkins] SVN: zdaemon/trunk/src/zdaemon/tests/testzdrun.py
testRunIgnoresParentSignals(): Try to fix an
Tim Peters
tim.one at comcast.net
Thu Dec 15 15:30:14 EST 2005
Log message for revision 40791:
testRunIgnoresParentSignals(): Try to fix an
intermittent test-killing race between this test
and zdrun.py fighting over who deletes the
test socket first.
Changed:
U zdaemon/trunk/src/zdaemon/tests/testzdrun.py
-=-
Modified: zdaemon/trunk/src/zdaemon/tests/testzdrun.py
===================================================================
--- zdaemon/trunk/src/zdaemon/tests/testzdrun.py 2005-12-15 16:58:31 UTC (rev 40790)
+++ zdaemon/trunk/src/zdaemon/tests/testzdrun.py 2005-12-15 20:30:13 UTC (rev 40791)
@@ -248,7 +248,22 @@
# Kill the process.
send_action('exit\n', zdrun_socket)
finally:
- shutil.rmtree(tmp)
+ # Remove the tmp directory.
+ # Caution: this is delicate. The code here used to do
+ # shutil.rmtree(tmp), but that suffers a sometimes-fatal
+ # race with zdrun.py. The 'testsock' socket is created
+ # by zdrun in the tmp directory, and zdrun tries to
+ # unlink it. If shutil.rmtree sees 'testsock' too, it
+ # will also try to unlink it, but zdrun may complete
+ # unlinking it before shutil gets to it (there's more
+ # than one process here). So, in effect, we code a
+ # 1-level rmtree inline here, suppressing errors.
+ for fname in os.listdir('.'):
+ try:
+ os.unlink(os.path.join(tmp, fname))
+ except os.error:
+ pass
+ os.rmdir(tmp)
def testUmask(self):
# people have a strange tendency to run the tests as root
More information about the Zope3-Checkins
mailing list