MCPcopy Create free account
hub / github.com/dask/dask / monkeypatch_cpu_count

Function monkeypatch_cpu_count

dask/tests/test_system.py:84–102  ·  view source on GitHub ↗
(monkeypatch)

Source from the content-addressed store, hash-verified

82
83@pytest.fixture
84def monkeypatch_cpu_count(monkeypatch):
85 def cpu_count():
86 return 250 # Absurdly high, unlikely to match real value
87
88 def sched_getaffinity(pid):
89 return set(range(250))
90
91 class Process:
92 def cpu_affinity(self):
93 return list(range(250))
94
95 monkeypatch.setattr(os, "cpu_count", cpu_count)
96 if sys.version_info >= (3, 13):
97 monkeypatch.setattr(os, "process_cpu_count", cpu_count)
98 monkeypatch.setattr(os, "sched_getaffinity", sched_getaffinity)
99 with suppress(ImportError):
100 import psutil
101
102 monkeypatch.setattr(psutil, "Process", Process)
103
104
105@pytest.mark.skipif(not LINUX, reason="Control Groups only available on Linux")

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected