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