MCPcopy Index your code
hub / github.com/dask/dask / test_cpu_affinity_psutil

Function test_cpu_affinity_psutil

dask/tests/test_system.py:26–40  ·  view source on GitHub ↗

Test that cpu_count() respects CPU affinity set by psutil

(affinity)

Source from the content-addressed store, hash-verified

24@pytest.mark.skipif(MACOS, reason="No CPU affinity in psutil")
25@pytest.mark.parametrize(("affinity"), [{0}, {1}, {0, 1}, {0, 2}])
26def test_cpu_affinity_psutil(affinity):
27 """Test that cpu_count() respects CPU affinity set by psutil"""
28 psutil = pytest.importorskip("psutil")
29 proc = psutil.Process()
30 prev = proc.cpu_affinity()
31 if prev is None:
32 pytest.skip("No support for CPU affinity")
33 if not affinity.issubset(set(prev)):
34 pytest.skip("Not enough CPUs") # pragma: no cover
35
36 proc.cpu_affinity(affinity)
37 try:
38 assert cpu_count() == len(affinity)
39 finally:
40 proc.cpu_affinity(prev)
41
42
43@pytest.mark.skipif(not LINUX, reason="No command line API for CPU affinity")

Callers

nothing calls this directly

Calls 4

cpu_affinityMethod · 0.95
cpu_countFunction · 0.90
setClass · 0.85
skipMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…