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

Commit5245b97

Browse files
authored
[3.12]gh-109649: Enhance os.cpu_count() documentation (#110169)
*gh-109649: Enhance os.cpu_count() documentation* Doc: Specify that os.cpu_count() counts *logicial* CPUs.* Doc: Specify that os.sched_getaffinity(0) is related to the calling thread.* Fix test_posix.test_sched_getaffinity(): restore the old CPU mask when the test completes!* Restore removed text
1 parentce332aa commit5245b97

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

‎Doc/library/os.rst

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5141,8 +5141,10 @@ operating system.
51415141

51425142
..function::sched_getaffinity(pid, /)
51435143

5144-
Return the set of CPUs the process with PID *pid* (or the current process
5145-
if zero) is restricted to.
5144+
Return the set of CPUs the process with PID *pid* is restricted to.
5145+
5146+
If *pid* is zero, return the set of CPUs the calling thread of the current
5147+
process is restricted to.
51465148

51475149

51485150
.. _os-path:
@@ -5183,12 +5185,12 @@ Miscellaneous System Information
51835185

51845186
..function::cpu_count()
51855187

5186-
Return the number of CPUs in the system. Returns ``None`` if undetermined.
5187-
5188-
This number is not equivalent to the number of CPUs the current process can
5189-
use. The number of usable CPUs can be obtained with
5190-
``len(os.sched_getaffinity(0))``
5188+
Return the number of logical CPUs in the system. Returns ``None`` if
5189+
undetermined.
51915190

5191+
This number is not equivalent to the number of logical CPUs the current
5192+
process can use. ``len(os.sched_getaffinity(0))`` gets the number of logical
5193+
CPUs the calling thread of the current process is restricted to
51925194

51935195
..versionadded::3.4
51945196

‎Lib/test/test_posix.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,6 +1205,7 @@ def test_sched_getaffinity(self):
12051205
@requires_sched_affinity
12061206
deftest_sched_setaffinity(self):
12071207
mask=posix.sched_getaffinity(0)
1208+
self.addCleanup(posix.sched_setaffinity,0,list(mask))
12081209
iflen(mask)>1:
12091210
# Empty masks are forbidden
12101211
mask.pop()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp