mirror of
git://git.yoctoproject.org/yocto-autobuilder2.git
synced 2025-07-04 20:54:48 +02:00
builders: Rework least loaded worker finding in nextWorker()
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
This commit is contained in:
parent
776469c3ae
commit
ea0077dce7
23
builders.py
23
builders.py
|
@ -178,25 +178,16 @@ def nextWorker(bldr, workers, buildrequest):
|
|||
[resultspec.Filter('complete', 'eq', [False])],
|
||||
)
|
||||
|
||||
active = {}
|
||||
maxbuilds = 0
|
||||
active = {worker.worker.workerid: 0 for worker in possible_workers}
|
||||
for build in builds:
|
||||
if build['workerid'] not in active:
|
||||
active[build['workerid']] = 1
|
||||
else:
|
||||
if build['workerid'] in active:
|
||||
active[build['workerid']] += 1
|
||||
if maxbuilds > active[build['workerid']]:
|
||||
maxbuilds = active[build['workerid']]
|
||||
least_actives = [k for k, v in active.items() if v == min(active.values())]
|
||||
|
||||
random.shuffle(possible_workers)
|
||||
|
||||
for worker in possible_workers:
|
||||
if worker.worker.workerid not in active:
|
||||
return worker
|
||||
for i in range(maxbuilds):
|
||||
for worker in possible_workers:
|
||||
if active[worker.worker.workerid] == i:
|
||||
return worker
|
||||
possible_workers = [worker for worker in possible_workers
|
||||
if worker.worker.workerid in least_actives]
|
||||
if possible_workers:
|
||||
return random.choice(possible_workers)
|
||||
|
||||
return None
|
||||
for w in possible_workers:
|
||||
|
|
Loading…
Reference in New Issue
Block a user