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.
--- 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: