Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
41be170
gh-109595: Add -Xcpu_count=<n> cmdline for container users
corona10 Sep 21, 2023
f7a7428
Check style
corona10 Sep 21, 2023
7009bbe
Add help
corona10 Sep 21, 2023
d1f91d8
Apply suggestions from code review
corona10 Sep 21, 2023
8c92ed6
Apply suggestions from code review
corona10 Sep 21, 2023
c27bdfc
Check style
corona10 Sep 21, 2023
b13e5ee
Address code review
corona10 Sep 21, 2023
45fce16
Address code review
corona10 Sep 21, 2023
49a48e4
Address code review
corona10 Sep 21, 2023
829a8e8
Address code review
corona10 Sep 21, 2023
cfb33a4
Fix test
corona10 Sep 21, 2023
95a2173
Update NEWS.d
corona10 Sep 21, 2023
0394d1d
Address code review
corona10 Sep 21, 2023
f4a3f01
Update
corona10 Sep 21, 2023
60a28fe
Update
corona10 Sep 21, 2023
7e5595c
nit
corona10 Sep 21, 2023
8678012
Update
corona10 Sep 21, 2023
cbc5484
Add PYTHONCPUCOUNT
corona10 Sep 21, 2023
4622b60
Add PYTHONCPUCOUNT
corona10 Sep 21, 2023
50f0178
Apply suggestions from code review
corona10 Sep 21, 2023
5c3ac68
Update Python/initconfig.c
corona10 Sep 21, 2023
a276bfd
Fix
corona10 Sep 21, 2023
9c582be
Update whatsnew
corona10 Sep 21, 2023
35b952f
nit
corona10 Sep 21, 2023
f04ea58
Check style
corona10 Sep 21, 2023
7ecf705
Fix docs
corona10 Sep 21, 2023
18dcd44
Update doc
corona10 Sep 21, 2023
b344f4f
nit
corona10 Sep 21, 2023
8069d21
Update
corona10 Sep 21, 2023
c70bc82
Update
corona10 Sep 21, 2023
c8abc29
Update
corona10 Sep 21, 2023
2ac6901
Address code review
corona10 Sep 21, 2023
f0a3ebf
Address code review
corona10 Sep 21, 2023
89d8bb2
Address Victor's suggestion
corona10 Sep 24, 2023
66c617f
nit
corona10 Sep 24, 2023
4a72ed4
Address Erlend's review
corona10 Sep 26, 2023
0426e3e
fix
corona10 Sep 26, 2023
ac5329b
Merge remote-tracking branch 'upstream/main' into gh-109595
corona10 Sep 30, 2023
e50e678
fix
corona10 Sep 30, 2023
24fe0e4
Add space
corona10 Sep 30, 2023
32843ed
Update os.py
corona10 Sep 30, 2023
a954f1c
nit
corona10 Sep 30, 2023
3ab2bc4
Add test code
corona10 Sep 30, 2023
7231697
Update docs
corona10 Sep 30, 2023
b18da0d
fix
corona10 Oct 1, 2023
3579fc4
Address code reivew
corona10 Oct 1, 2023
134ed9e
Address code review
corona10 Oct 1, 2023
2bec7f4
Add test
corona10 Oct 1, 2023
9f7cb5e
fix
corona10 Oct 1, 2023
1217ab5
fix
corona10 Oct 1, 2023
64da2f9
fix
corona10 Oct 1, 2023
64c7329
fix
corona10 Oct 1, 2023
cc54afb
Update
corona10 Oct 1, 2023
ba421c7
Address code review
corona10 Oct 1, 2023
5f20bf6
Update NEWS.d
corona10 Oct 1, 2023
c11789b
Update
corona10 Oct 1, 2023
936c182
Update
corona10 Oct 1, 2023
2f0dc1c
Address code review
corona10 Oct 1, 2023
a7b2c88
Rename to PYTHON_CPU_COUNT
corona10 Oct 1, 2023
551c76d
Hidden overrided cpu count
corona10 Oct 2, 2023
75021be
Use overridden
corona10 Oct 2, 2023
57dd53b
Minor refactoring
corona10 Oct 2, 2023
3f9da50
Revert to PYTHONCPUCOUNT
corona10 Oct 2, 2023
57e82c5
fix
corona10 Oct 2, 2023
c37c8d0
Use PYTHON_CPU_COUNT
corona10 Oct 3, 2023
c7726e5
Address Greg's review
corona10 Oct 3, 2023
de8bf53
Address Greg's code review
corona10 Oct 3, 2023
633914b
nit
corona10 Oct 3, 2023
37fbdfe
Include multiprocessing in docs, reword.
gpshead Oct 3, 2023
a0cfb21
Merge remote-tracking branch 'upstream/main' into gh-109595
corona10 Oct 3, 2023
8daa3b7
Merge remote-tracking branch 'upstream/main' into gh-109595
corona10 Oct 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address code review
  • Loading branch information
corona10 committed Sep 21, 2023
commit 2ac6901e4351a837180d928b96e460bd53aafe3c
2 changes: 1 addition & 1 deletion Doc/using/cmdline.rst
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ Miscellaneous options
will do nothing if is not supported on the current system. The default value
is "off". See also :envvar:`PYTHONPERFSUPPORT` and :ref:`perf_profiling`.
* :samp:`-X cpu_count={n}` overrides :func:`os.cpu_count`.
And *n* must be greater than 0.
*n* must be greater than or equal to 1.
This option is useful for users who need to limit CPU resources of a container system.
See also :envvar:`PYTHONCPUCOUNT`.

Expand Down
2 changes: 1 addition & 1 deletion Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ os
--

* :func:`os.cpu_count` can be overrided through the new
environment variable :envvar:`PYTHONCPUCOUNT`, the new command-line option
environment variable :envvar:`PYTHONCPUCOUNT` or the new command-line option
:option:`-X cpu_count <-X>`. This option is useful for users who need to limit
CPU resources of a container system.(Contributed by Donghee Na in :gh:`109595`)

Expand Down
1 change: 1 addition & 0 deletions Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -14353,6 +14353,7 @@ os_cpu_count_impl(PyObject *module)
if (config->cpu_count > 0) {
return PyLong_FromLong(config->cpu_count);
}

int ncpu = 0;
#ifdef MS_WINDOWS
#ifdef MS_WINDOWS_DESKTOP
Expand Down
3 changes: 2 additions & 1 deletion Python/initconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -1690,9 +1690,9 @@ config_read_env_vars(PyConfig *config)
static PyStatus
config_init_cpu_count(PyConfig *config)
{
int cpu_count = -1;
const char *env = config_get_env(config, "PYTHONCPUCOUNT");
if (env) {
int cpu_count = -1;
if (_Py_str_to_int(env, &cpu_count) != 0) {
cpu_count = -1;
}
Expand All @@ -1702,6 +1702,7 @@ config_init_cpu_count(PyConfig *config)
}
const wchar_t *xoption = config_get_xoption(config, L"cpu_count");
if (xoption) {
int cpu_count = -1;
const wchar_t *sep = wcschr(xoption, L'=');
if (sep) {
if (config_wstr_to_int(sep + 1, &cpu_count) < 0 || cpu_count < 1) {
Expand Down