Mercurial > hg
changeset 49215:8d31ef3017c9 stable
run-tests: prevent race-condition when picking a channel
Before this, multiple jobs could search the list at the same time and pick the
same free channel.
We now project this search/assignment with a simple lock.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 24 May 2022 10:34:42 +0200 |
parents | eca367970253 |
children | 9ea9445c3223 |
files | tests/run-tests.py |
diffstat | 1 files changed, 9 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/run-tests.py Tue May 24 09:57:53 2022 +0200 +++ b/tests/run-tests.py Tue May 24 10:34:42 2022 +0200 @@ -2553,16 +2553,18 @@ done = queue.Queue() running = 0 + channels_lock = threading.Lock() channels = [""] * self._jobs def job(test, result): - for n, v in enumerate(channels): - if not v: - channel = n - break - else: - raise ValueError('Could not find output channel') - channels[channel] = "=" + test.name[5:].split(".")[0] + with channels_lock: + for n, v in enumerate(channels): + if not v: + channel = n + break + else: + raise ValueError('Could not find output channel') + channels[channel] = "=" + test.name[5:].split(".")[0] r = None try: