summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Henkel <tobias.henkel@bmw.de>2019-03-06 20:01:26 +0100
committerTobias Henkel <tobias.henkel@bmw.de>2019-03-06 20:01:26 +0100
commitf5c6e37c84094df70539bad0db14c77cd26ec080 (patch)
tree30658fb5d88fce5758d2f58f64a18302dbca2da2
parent967828b1f05a2676b1c06714add052108a9f3102 (diff)
Fix test race with Watchdog thread still running
In some rare occasions the watchdog thread is still sleeping [1] while a test case is already finished. In this case the running thread validation fails the test. This can be solved by not sleeping for a fixed amount of time but instead wait the same time for a stop event. This makes the thread stop immediately when it is asked to stop [1] Trace File "/usr/lib/python3.5/threading.py", line 882, in _bootstrap self._bootstrap_inner() File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner self.run() File "/usr/lib/python3.5/threading.py", line 862, in run self._target(*self._args, **self._kwargs) File "/home/zuul/src/git.openstack.org/openstack-infra/zuul/zuul/executor/server.py", line 185, in _run time.sleep(10) Change-Id: I45eba5bf8f46de078fd8093719ef84e5229eafeb
Notes
Notes (review): Code-Review+2: James E. Blair <corvus@inaugust.com> Code-Review+2: Clark Boylan <cboylan@sapwetik.org> Workflow+1: Clark Boylan <cboylan@sapwetik.org> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Wed, 06 Mar 2019 20:10:36 +0000 Reviewed-on: https://review.openstack.org/641473 Project: openstack-infra/zuul Branch: refs/heads/master
-rw-r--r--zuul/executor/server.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/zuul/executor/server.py b/zuul/executor/server.py
index 4413175..de76471 100644
--- a/zuul/executor/server.py
+++ b/zuul/executor/server.py
@@ -179,9 +179,14 @@ class Watchdog(object):
179 self.thread.daemon = True 179 self.thread.daemon = True
180 self.timed_out = None 180 self.timed_out = None
181 181
182 self.end = 0
183
184 self._running = False
185 self._stop_event = threading.Event()
186
182 def _run(self): 187 def _run(self):
183 while self._running and time.time() < self.end: 188 while self._running and time.time() < self.end:
184 time.sleep(10) 189 self._stop_event.wait(10)
185 if self._running: 190 if self._running:
186 self.timed_out = True 191 self.timed_out = True
187 self.function(*self.args) 192 self.function(*self.args)
@@ -198,6 +203,7 @@ class Watchdog(object):
198 203
199 def stop(self): 204 def stop(self):
200 self._running = False 205 self._running = False
206 self._stop_event.set()
201 207
202 208
203class SshAgent(object): 209class SshAgent(object):