From patchwork Fri Jan 22 19:00:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: run-tests: "fix" race condition in race condition fix From: Bryan O'Sullivan X-Patchwork-Id: 12868 Message-Id: <6bb64e83ac188ee99528.1453489217@bryano-mbp.local> To: mercurial-devel@selenic.com Date: Fri, 22 Jan 2016 11:00:17 -0800 # HG changeset patch # User Bryan O'Sullivan # Date 1453489213 28800 # Fri Jan 22 11:00:13 2016 -0800 # Branch stable # Node ID 6bb64e83ac188ee99528ad0237028f00047ab505 # Parent 0b752757a0c4f30ac755389014e2af9d2e0b4a3f run-tests: "fix" race condition in race condition fix Laurent's commit 3203dfe341f9 still suffers from a race: by the time the "job" function tries to assign to channels[channel], that list has been truncated to empty. The result is that every job thread raises an IndexError. Earlier, I tried an approach of correctly locking channels, but that caused run-tests to hang on KeyboardInterrupt sometimes. This approach is strictly hackier, but seems to actually work reliably. diff --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -1526,13 +1526,16 @@ class TestSuite(unittest.TestSuite): channels[channel] = "=" + test.name[5:].split(".")[0] try: test(result) - channels[channel] = '' done.put(None) except KeyboardInterrupt: - channels[channel] = '' + pass except: # re-raises done.put(('!', test, 'run-test raised an error, see traceback')) raise + try: + channels[channel] = '' + except IndexError: + pass def stat(): count = 0