Blame SOURCES/0003-Use-thread.join-timeout-to-avoid-busy-waiting-and-si.patch

816461
From aa77652e8ec5d7cbe14e09133e58a45d92cf3720 Mon Sep 17 00:00:00 2001
816461
From: Derek Horton <dehort@redhat.com>
816461
Date: Fri, 5 Aug 2022 15:02:37 -0500
816461
Subject: [PATCH] Use thread.join(timeout) to avoid busy waiting and simplify
816461
 interval event posting logic
816461
816461
Resolves: rhbz#2137005
816461
816461
(cherry picked from commit 478930cca7a8d4acf21aef0715e42052315cb24e)
816461
---
816461
 rhc_worker_playbook/server.py | 12 +++---------
816461
 1 file changed, 3 insertions(+), 9 deletions(-)
816461
816461
diff --git a/rhc_worker_playbook/server.py b/rhc_worker_playbook/server.py
816461
index 8e9826f..e41482d 100644
816461
--- a/rhc_worker_playbook/server.py
816461
+++ b/rhc_worker_playbook/server.py
816461
@@ -231,20 +231,14 @@ class WorkerService(yggdrasil_pb2_grpc.WorkerServicer):
816461
             artifact_dir=RUNNER_ARTIFACTS_DIR,
816461
             rotate_artifacts=RUNNER_ROTATE_ARTIFACTS)
816461
 
816461
-        # initialize elapsed counter
816461
-        elapsedTime = 0
816461
-        startTime = time.time()
816461
+        # wait for the thread to finish
816461
         while runnerThread.is_alive():
816461
-            time.sleep(1)
816461
-            elapsedTime = time.time() - startTime
816461
-            if elapsedTime >= response_interval:
816461
+            runnerThread.join(response_interval)
816461
+            if runnerThread.is_alive():
816461
                 # hit the interval, post events
816461
                 _log("Hit the response interval. Posting current status...")
816461
                 returnedEvents = _composeDispatcherMessage(events, return_url, response_to)
816461
                 response = self.dispatcher.Send(returnedEvents)
816461
-                # reset interval timer
816461
-                elapsedTime = 0
816461
-                startTime = time.time()
816461
 
816461
         if runner.status == 'failed':
816461
             # last event sould be the failure, find the reason