Method: pylint.lint.run._cpu_count
Calls: 2, Exceptions: 0, Paths: 2Back
Path 1: 1 calls (0.5)
8 (1)
1def _cpu_count() -> int:
2 """Use sched_affinity if available for virtualized or containerized
3 environments.
4 """
5 cpu_share = _query_cpu()
6 cpu_count = None
7 sched_getaffinity = getattr(os, "sched_getaffinity", None)
8 # pylint: disable=not-callable,using-constant-test,useless-suppression
9 if sched_getaffinity:
10 cpu_count = len(sched_getaffinity(0))
11 elif multiprocessing:
12 cpu_count = multiprocessing.cpu_count()
13 else:
14 cpu_count = 1
15 if sys.platform == "win32":
16 # See also https://github.com/python/cpython/issues/94242
17 cpu_count = min(cpu_count, 56) # pragma: no cover
18 if cpu_share is not None:
19 return min(cpu_share, cpu_count)
20 return cpu_count
Path 2: 1 calls (0.5)
1 (1)
1def _cpu_count() -> int:
2 """Use sched_affinity if available for virtualized or containerized
3 environments.
4 """
5 cpu_share = _query_cpu()
6 cpu_count = None
7 sched_getaffinity = getattr(os, "sched_getaffinity", None)
8 # pylint: disable=not-callable,using-constant-test,useless-suppression
9 if sched_getaffinity:
10 cpu_count = len(sched_getaffinity(0))
11 elif multiprocessing:
12 cpu_count = multiprocessing.cpu_count()
13 else:
14 cpu_count = 1
15 if sys.platform == "win32":
16 # See also https://github.com/python/cpython/issues/94242
17 cpu_count = min(cpu_count, 56) # pragma: no cover
18 if cpu_share is not None:
19 return min(cpu_share, cpu_count)
20 return cpu_count