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

Function test_cpu_count_cgroups

dask/tests/test_system.py:107–128  ·  view source on GitHub ↗
(dirname, monkeypatch, monkeypatch_cpu_count)

Source from the content-addressed store, hash-verified

105@pytest.mark.skipif(not LINUX, reason="Control Groups only available on Linux")
106@pytest.mark.parametrize("dirname", ["cpuacct,cpu", "cpu,cpuacct", None])
107def test_cpu_count_cgroups(dirname, monkeypatch, monkeypatch_cpu_count):
108 if dirname:
109 paths = {
110 f"/sys/fs/cgroup/{dirname}/cpu.cfs_quota_us": io.StringIO("2005"),
111 f"/sys/fs/cgroup/{dirname}/cpu.cfs_period_us": io.StringIO("10"),
112 }
113 builtin_open = builtins.open
114
115 def myopen(path, *args, **kwargs):
116 if path in paths:
117 return paths.get(path)
118 return builtin_open(path, *args, **kwargs)
119
120 monkeypatch.setattr(builtins, "open", myopen)
121 monkeypatch.setattr(sys, "platform", "linux")
122
123 count = cpu_count()
124 if dirname:
125 # Rounds up
126 assert count == 201
127 else:
128 assert count == 250
129
130
131@pytest.mark.skipif(not LINUX, reason="Control Groups only available on Linux")

Callers

nothing calls this directly

Calls 1

cpu_countFunction · 0.90

Tested by

no test coverage detected