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

Skip to content

Commit 2ac6901

Browse files
committed
Address code review
1 parent c8abc29 commit 2ac6901

File tree

4 files changed

+5
-3
lines changed

4 files changed

+5
-3
lines changed

Doc/using/cmdline.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ Miscellaneous options
547547
will do nothing if is not supported on the current system. The default value
548548
is "off". See also :envvar:`PYTHONPERFSUPPORT` and :ref:`perf_profiling`.
549549
* :samp:`-X cpu_count={n}` overrides :func:`os.cpu_count`.
550-
And *n* must be greater than 0.
550+
*n* must be greater than or equal to 1.
551551
This option is useful for users who need to limit CPU resources of a container system.
552552
See also :envvar:`PYTHONCPUCOUNT`.
553553

Doc/whatsnew/3.13.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ os
167167
--
168168

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

Modules/posixmodule.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14353,6 +14353,7 @@ os_cpu_count_impl(PyObject *module)
1435314353
if (config->cpu_count > 0) {
1435414354
return PyLong_FromLong(config->cpu_count);
1435514355
}
14356+
1435614357
int ncpu = 0;
1435714358
#ifdef MS_WINDOWS
1435814359
#ifdef MS_WINDOWS_DESKTOP

Python/initconfig.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1690,9 +1690,9 @@ config_read_env_vars(PyConfig *config)
16901690
static PyStatus
16911691
config_init_cpu_count(PyConfig *config)
16921692
{
1693-
int cpu_count = -1;
16941693
const char *env = config_get_env(config, "PYTHONCPUCOUNT");
16951694
if (env) {
1695+
int cpu_count = -1;
16961696
if (_Py_str_to_int(env, &cpu_count) != 0) {
16971697
cpu_count = -1;
16981698
}
@@ -1702,6 +1702,7 @@ config_init_cpu_count(PyConfig *config)
17021702
}
17031703
const wchar_t *xoption = config_get_xoption(config, L"cpu_count");
17041704
if (xoption) {
1705+
int cpu_count = -1;
17051706
const wchar_t *sep = wcschr(xoption, L'=');
17061707
if (sep) {
17071708
if (config_wstr_to_int(sep + 1, &cpu_count) < 0 || cpu_count < 1) {

0 commit comments

Comments
 (0)