Skip to content

Commit

Permalink
Merge pull request JohnHammond#9 from JohnHammond/fix_issue8
Browse files Browse the repository at this point in the history
Added check for availability of os.sched_getaffinity.
  • Loading branch information
calebstewart authored Apr 24, 2020
2 parents 6094273 + fea0b47 commit 5b1a17c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion katana/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def __init__(self, monitor: Monitor = None, config_path=None, default_units=True
# Default values for configuration items
self["DEFAULT"] = {
"units": "",
"threads": len(os.sched_getaffinity(0)),
"threads": 4,
"outdir": "./results",
"auto": False,
"recurse": True,
Expand All @@ -85,6 +85,15 @@ def __init__(self, monitor: Monitor = None, config_path=None, default_units=True
if "manager" not in self:
self["manager"] = {}

try:
self["DEFAULT"]["threads"] = str(len(os.sched_getaffinity(0)))
except AttributeError:
# os.sched_getaffinity does not exist. We fallback to
# multiprocessing
import multiprocessing

self["DEFAULT"]["threads"] = str(multiprocessing.cpu_count())

# Load a configuration file if specified
if config_path is not None and len(self.read(config_path)) == 0:
raise RuntimeError("{0}: configuration file not found")
Expand Down

0 comments on commit 5b1a17c

Please sign in to comment.