Skip to content

Commit

Permalink
fix(api): prefer device with lower index when queue is tied
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Feb 4, 2023
1 parent d75cd50 commit 13510db
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion api/onnx_web/device_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,11 @@ def get_next_device(self):
queued = job_counts.most_common()
logger.debug('jobs queued by device: %s', queued)

return queued[-1][0]
lowest_count = queued[-1][1]
lowest_devices = [d[0] for d in queued if d[1] == lowest_count]
lowest_devices.sort()

return lowest_devices[0]

def prune(self):
self.jobs[:] = [job for job in self.jobs if job.future.done()]
Expand Down

0 comments on commit 13510db

Please sign in to comment.