build-unit-test-docker: prevent exception in thread start-up
Add a lock to allow all the threads to start before they start
running, so that one thread doesn't 'join' on its dependency
before the dependency starts. This shows as an exception:
Traceback (most recent call last):
File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "./scripts/build-unit-test-docker", line 353, in run
deppkg.join()
File "/usr/lib/python3.8/threading.py", line 1006, in join
raise RuntimeError("cannot join thread before it is started")
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I7594ac393f310085eb8328a0394493c01b78add3
diff --git a/scripts/build-unit-test-docker b/scripts/build-unit-test-docker
index ae34417..da03dca 100755
--- a/scripts/build-unit-test-docker
+++ b/scripts/build-unit-test-docker
@@ -385,8 +385,14 @@
pkg_threads = [Package(p) for p in cls.packages.keys()]
# Start building them all.
+ # This section is locked because threads depend on each other,
+ # based on the packages, and they cannot 'join' on a thread
+ # which is not yet started. Adding a lock here allows all the
+ # threads to start before they 'join' their dependencies.
+ Package.lock.acquire()
for t in pkg_threads:
t.start()
+ Package.lock.release()
# Wait for completion.
for t in pkg_threads: