Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def threadpool_info_from_subprocess(module):
"""Utility to call threadpool_info in a subprocess
`module` is imported before calling threadpool_info
"""
# set PYTHONPATH to import from non sub-modules
path1 = normpath(dirname(threadpoolctl.__file__))
path2 = os.path.join(path1, "tests", "_openmp_test_helper")
pythonpath = os.pathsep.join([path1, path2])
env = os.environ.copy()
try:
env["PYTHONPATH"] = os.pathsep.join([pythonpath, env["PYTHONPATH"]])
except KeyError:
env["PYTHONPATH"] = pythonpath
cmd = [sys.executable, "-m", "threadpoolctl", "-i", module]
out = check_output(cmd, env=env).decode("utf-8")
return json.loads(out)