summaryrefslogtreecommitdiff
path: root/zephyr/zmake/zmake/multiproc.py
diff options
context:
space:
mode:
authorYuval Peress <peress@chromium.org>2021-07-09 12:04:01 -0600
committerCommit Bot <commit-bot@chromium.org>2021-07-09 19:40:37 +0000
commit7dea3f0835af95710717b9370b703bdb53ce0ee3 (patch)
tree7b645d4ed07d8a86f39017dc1d5fc48360dacbbb /zephyr/zmake/zmake/multiproc.py
parent54207d9ee79bd58fb8ba0cab8e7b164f08ba93e2 (diff)
downloadchrome-ec-7dea3f0835af95710717b9370b703bdb53ce0ee3.tar.gz
zmake: lazily create the logging thread
The logging thread was crashing the test_zmake.py logic that is using the TestCase class. It seems that pytest was triggering the logging thread to die (since it's set up as a daemon) when one TestCase finished running. This caused the next TestCase to run into the .start() call which crashed since we can't start the same thread multiple times. BRANCH=none BUG=none TEST=zmake testall TEST=pytest zephyr/zmake/tests Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: I389f483a1d30d4ac21aaf547cd84c8adb9d8aa24 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3017598 Commit-Queue: Keith Short <keithshort@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'zephyr/zmake/zmake/multiproc.py')
-rw-r--r--zephyr/zmake/zmake/multiproc.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/zephyr/zmake/zmake/multiproc.py b/zephyr/zmake/zmake/multiproc.py
index f35ad8d1ab..19e5aefef4 100644
--- a/zephyr/zmake/zmake/multiproc.py
+++ b/zephyr/zmake/zmake/multiproc.py
@@ -163,7 +163,7 @@ def _logging_loop():
_log_fd(fd)
-_logging_thread = threading.Thread(target=_logging_loop, daemon=True)
+_logging_thread = None
def log_output(logger, log_level, file_descriptor,
@@ -182,13 +182,18 @@ def log_output(logger, log_level, file_descriptor,
LogWriter object for the resulting output
"""
with _logging_cv:
- if not _logging_thread.is_alive():
+ global _logging_thread
+ if _logging_thread is None or not _logging_thread.is_alive():
+ # First pass or thread must have died, create a new one.
+ _logging_thread = threading.Thread(target=_logging_loop,
+ daemon=True)
_logging_thread.start()
+
writer = LogWriter(
- logger,
- log_level,
- log_level_override_func,
- job_id)
+ logger,
+ log_level,
+ log_level_override_func,
+ job_id)
_logging_map[file_descriptor] = writer
# Write a dummy byte to the pipe to break the select so we can add the
# new fd.