Skip to content

Commit

Permalink
Work around dotnet#7371
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
MattGal committed Jun 2, 2021
1 parent c7d6bd6 commit 702da8b
Showing 1 changed file with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import re
import sys
import time
import traceback
import logging
from queue import Queue
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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")]):
Expand Down

0 comments on commit 702da8b

Please sign in to comment.