Skip to content

Commit

Permalink
BUG: Incorrect calculation of free cores.
Browse files Browse the repository at this point in the history
When calculating the actual free cores, we were looking at the number of
free cores and subtracting the number of cores used which essentially
double counts the cores that are used since free will be lower when the
cores are being used.  We now subtract the number of used cores from the
total available to decide if we can run the job.
  • Loading branch information
prabhuramachandran committed Sep 30, 2018
1 parent 7fe6edc commit 4df4ef3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion automan/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ class Worker(object):
def __init__(self):
self.jobs = dict()
self.running_jobs = set()
self._total_cores = psutil.cpu_count(logical=False)

def _check_running_jobs(self):
for i in self.running_jobs.copy():
Expand All @@ -243,7 +244,7 @@ def can_run(self, n_core):
n_cores_used = sum(
[jobs[i].n_core for i in self.running_jobs]
)
if (free - n_cores_used) >= n_core:
if (self._total_cores - n_cores_used) >= n_core:
result = True
return result

Expand Down

0 comments on commit 4df4ef3

Please sign in to comment.