From 702da8b5ac6913242892d25a376e6c3ac60d5225 Mon Sep 17 00:00:00 2001 From: Matt Galbraith Date: Fri, 28 May 2021 11:45:21 -0700 Subject: [PATCH] Work around https://github.com/dotnet/arcade/issues/7371 - Don't have a threading contention for stdout by only using stdout in the exception case; "starting..." adds minimal value, one can assume if the script is called it starts. - sleep() the main thread 5s before accessing stdout in case the exception case wants to happen - Remove most non-error-path logging since it adds little value and multiple threads competing for stdout can cause un-catch-able failure. --- .../Sdk/tools/azure-pipelines/reporter/run.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/Microsoft.DotNet.Helix/Sdk/tools/azure-pipelines/reporter/run.py b/src/Microsoft.DotNet.Helix/Sdk/tools/azure-pipelines/reporter/run.py index deaaa25136c..e862eb2335d 100644 --- a/src/Microsoft.DotNet.Helix/Sdk/tools/azure-pipelines/reporter/run.py +++ b/src/Microsoft.DotNet.Helix/Sdk/tools/azure-pipelines/reporter/run.py @@ -1,6 +1,7 @@ import os import re import sys +import time import traceback import logging from queue import Queue @@ -35,11 +36,9 @@ def __print(self, msg): def __process(self, batch): self.publisher.upload_batch(batch) self.total_uploaded = self.total_uploaded + len(batch) - self.__print('uploaded {} results'.format(self.total_uploaded)) def run(self): global workerFailed, workerFailedLock - self.__print("starting...") while True: try: item = self.queue.get() @@ -146,26 +145,20 @@ def main(): worker.daemon = True worker.start() - log.info("Beginning to read test results...") + # https://github.com/dotnet/arcade/issues/7371 - trying to avoid contention for stdout + time.sleep(5) # In case the user puts the results in HELIX_WORKITEM_UPLOAD_ROOT for upload, check there too. - all_results = read_results([os.getcwd(), - get_env("HELIX_WORKITEM_UPLOAD_ROOT")]) + all_results = read_results([os.getcwd(), get_env("HELIX_WORKITEM_UPLOAD_ROOT")]) batch_size = 1000 batches = batch(all_results, batch_size) - log.info("Uploading results in batches of size {}".format(batch_size)) - for b in batches: q.put(b) - log.info("Main thread finished queueing batches") - q.join() - log.info("Main thread exiting") - with workerFailedLock: if workerFailed: if check_passed_to_workaround_ado_api_failure([os.getcwd(), get_env("HELIX_WORKITEM_UPLOAD_ROOT")]):