Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
aa929273
Commit
aa929273
authored
Sep 11, 2019
by
Steve Dower
Committed by
Zachary Ware
Sep 11, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-33166: Change os.cpu_count to return active (real) processors (GH-15949)
parent
e20134f8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
17 deletions
+5
-17
Misc/NEWS.d/next/Windows/2019-09-11-14-42-04.bpo-36634.8Un8ih.rst
...S.d/next/Windows/2019-09-11-14-42-04.bpo-36634.8Un8ih.rst
+2
-0
Modules/posixmodule.c
Modules/posixmodule.c
+3
-17
No files found.
Misc/NEWS.d/next/Windows/2019-09-11-14-42-04.bpo-36634.8Un8ih.rst
0 → 100644
View file @
aa929273
:func:`os.cpu_count` now returns active processors rather than maximum
processors.
Modules/posixmodule.c
View file @
aa929273
...
...
@@ -12204,23 +12204,9 @@ os_cpu_count_impl(PyObject *module)
{
int
ncpu
=
0
;
#ifdef MS_WINDOWS
/* Vista is supported and the GetMaximumProcessorCount API is Win7+
Need to fallback to Vista behavior if this call isn't present */
HINSTANCE
hKernel32
;
static
DWORD
(
CALLBACK
*
_GetMaximumProcessorCount
)(
WORD
)
=
NULL
;
Py_BEGIN_ALLOW_THREADS
hKernel32
=
GetModuleHandleW
(
L"KERNEL32"
);
*
(
FARPROC
*
)
&
_GetMaximumProcessorCount
=
GetProcAddress
(
hKernel32
,
"GetMaximumProcessorCount"
);
Py_END_ALLOW_THREADS
if
(
_GetMaximumProcessorCount
!=
NULL
)
{
ncpu
=
_GetMaximumProcessorCount
(
ALL_PROCESSOR_GROUPS
);
}
else
{
SYSTEM_INFO
sysinfo
;
GetSystemInfo
(
&
sysinfo
);
ncpu
=
sysinfo
.
dwNumberOfProcessors
;
}
/* Declare prototype here to avoid pulling in all of the Win7 APIs in 3.8 */
DWORD
WINAPI
GetActiveProcessorCount
(
WORD
group
);
ncpu
=
GetActiveProcessorCount
(
ALL_PROCESSOR_GROUPS
);
#elif defined(__hpux)
ncpu
=
mpctl
(
MPC_GETNUMSPUS
,
NULL
,
NULL
);
#elif defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment