Skip to content

Commit eca1479

Browse files
committed
More changes to collecting DUTs
Handle FileNotFoundError (when overwriting config file) Look for DUT only if queue is not empty Signed-off-by: Daniel Madej <[email protected]>
1 parent 151c1cd commit eca1479

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

common.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ def __access(self):
2828
self.last_modify = os.path.getmtime(self.path)
2929

3030
def need_reload(self):
31-
return self.last_modify != os.path.getmtime(self.path)
31+
try:
32+
return self.last_modify != os.path.getmtime(self.path)
33+
except FileNotFoundError:
34+
self.last_modify = 0
35+
raise
3236

3337
def load(self):
3438
with meta_lock:

runnerd

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,15 @@ class DutsManager:
133133

134134
def collect_duts(self):
135135
with self.lock:
136-
if not self.duts_config_file.need_reload():
137-
return
138-
136+
while True:
137+
try:
138+
if not self.duts_config_file.need_reload():
139+
return
140+
else:
141+
break
142+
except FileNotFoundError:
143+
pass
144+
log.info("Reloading DUTs config...")
139145
self.duts_config = self.duts_config_file.load()
140146
configured_duts = self.duts_config.get('duts', [])
141147
if configured_duts is None:
@@ -160,7 +166,7 @@ class DutsManager:
160166

161167
def get_free_dut(self):
162168
dut = None
163-
for _ in self.duts:
169+
while self.duts_queue.qsize():
164170
free_dut = self.duts_queue.get()
165171
if free_dut.ip in self.duts:
166172
dut = free_dut
@@ -287,6 +293,8 @@ class MasterRunner:
287293

288294
def run(self):
289295
def test_run_complete(dut, test_event):
296+
# Sometimes mark_free is quicker than reaching collect_duts in the loop below what
297+
# results in queuing next test on removed DUT. collect_duts here prevents that.
290298
self.duts_manager.collect_duts()
291299
self.duts_manager.mark_free(dut)
292300
test_event['end-timestamp'] = time.time()
@@ -295,16 +303,16 @@ class MasterRunner:
295303

296304
while True:
297305
self.duts_manager.collect_duts()
298-
if not self.duts_manager.duts:
306+
if not self.duts_manager.duts_queue.qsize():
299307
continue
300-
log.debug("Looking for free DUT... ")
308+
log.debug("Looking for a free DUT... ")
301309
try:
302310
dut = self.duts_manager.get_free_dut()
303311
except LookupError:
304312
log.warning("No available DUTs found!")
305313
continue
306314
log.debug(f"Found DUT {dut.ip}")
307-
log.debug("Looking for next test... ")
315+
log.debug("Looking for the next test... ")
308316
test_event = self.test_manager.get_next_test()
309317
log.debug(f"Found test {test_event}")
310318
test_event['ip'] = dut.ip

0 commit comments

Comments
 (0)