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

Commitbf6843e

Browse files
[3.11] [3.12]gh-109649: Enhance os.cpu_count() documentation (GH-110169) (#110226)
[3.12]gh-109649: Enhance os.cpu_count() documentation (GH-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(cherry picked from commit5245b97)Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent981696e commitbf6843e

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
@@ -4872,8 +4872,10 @@ operating system.
48724872

48734873
..function::sched_getaffinity(pid, /)
48744874

4875-
Return the set of CPUs the process with PID *pid* (or the current process
4876-
if zero) is restricted to.
4875+
Return the set of CPUs the process with PID *pid* is restricted to.
4876+
4877+
If *pid* is zero, return the set of CPUs the calling thread of the current
4878+
process is restricted to.
48774879

48784880

48794881
.. _os-path:
@@ -4914,12 +4916,12 @@ Miscellaneous System Information
49144916

49154917
..function::cpu_count()
49164918

4917-
Return the number of CPUs in the system. Returns ``None`` if undetermined.
4918-
4919-
This number is not equivalent to the number of CPUs the current process can
4920-
use. The number of usable CPUs can be obtained with
4921-
``len(os.sched_getaffinity(0))``
4919+
Return the number of logical CPUs in the system. Returns ``None`` if
4920+
undetermined.
49224921

4922+
This number is not equivalent to the number of logical CPUs the current
4923+
process can use. ``len(os.sched_getaffinity(0))`` gets the number of logical
4924+
CPUs the calling thread of the current process is restricted to
49234925

49244926
..versionadded::3.4
49254927

‎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