Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit244e37b

Browse files
authored
gh-109649: Fix test_os.test_process_cpu_count_affinity() (#111689)
When CPUs are isolated on Linux, os.process_cpu_count() is smallerthan os.cpu_count(). Fix the test for this case.Example with "isolcpus=5,11 rcu_nocbs=5,11" options passed to a Linuxcommand line to isolated two logical CPUs:$ ./python -c 'import os; print(os.process_cpu_count(), "/", os.cpu_count())'10 / 12
1 parentf21b230 commit244e37b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

‎Lib/test/test_os.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4342,8 +4342,8 @@ def test_process_cpu_count(self):
43424342
@unittest.skipUnless(hasattr(os,'sched_setaffinity'),
43434343
"don't have sched affinity support")
43444344
deftest_process_cpu_count_affinity(self):
4345-
ncpu=os.cpu_count()
4346-
ifncpuisNone:
4345+
affinity1=os.process_cpu_count()
4346+
ifaffinity1isNone:
43474347
self.skipTest("Could not determine the number of CPUs")
43484348

43494349
# Disable one CPU
@@ -4356,8 +4356,8 @@ def test_process_cpu_count_affinity(self):
43564356
os.sched_setaffinity(0,mask)
43574357

43584358
# test process_cpu_count()
4359-
affinity=os.process_cpu_count()
4360-
self.assertEqual(affinity,ncpu-1)
4359+
affinity2=os.process_cpu_count()
4360+
self.assertEqual(affinity2,affinity1-1)
43614361

43624362

43634363
# FD inheritance check is only useful for systems with process support.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp