log.debug(" No connections open")
return
- # Process all connections
+ builders = {}
+
+ # Map all connections by builder
for connection in connections:
- builder = connection.builder
+ builders[connection.builder] = connection
- log.debug(" Processing connection for %s" % builder)
+ # Process all builders and assign jobs
+ # We prioritize builders with fewer jobs
+ for builder in sorted(builders, key=lambda b: len(b.jobs)):
+ log.debug(" Processing builder %s" % builder)
with backend.db.transaction():
if not builder.is_ready():
job.builder = builder
+ # Find the connection
+ connection = builders[builder]
+
# Send the job to the builder
connection.assign_job(job)