File tree Expand file tree Collapse file tree 4 files changed +5
-3
lines changed Expand file tree Collapse file tree 4 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -547,7 +547,7 @@ Miscellaneous options
547
547
will do nothing if is not supported on the current system. The default value
548
548
is "off". See also :envvar: `PYTHONPERFSUPPORT ` and :ref: `perf_profiling `.
549
549
* :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 .
551
551
This option is useful for users who need to limit CPU resources of a container system.
552
552
See also :envvar: `PYTHONCPUCOUNT `.
553
553
Original file line number Diff line number Diff line change 167
167
--
168
168
169
169
* :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
171
171
:option: `-X cpu_count <-X> `. This option is useful for users who need to limit
172
172
CPU resources of a container system.(Contributed by Donghee Na in :gh: `109595 `)
173
173
Original file line number Diff line number Diff line change @@ -14353,6 +14353,7 @@ os_cpu_count_impl(PyObject *module)
14353
14353
if (config -> cpu_count > 0 ) {
14354
14354
return PyLong_FromLong (config -> cpu_count );
14355
14355
}
14356
+
14356
14357
int ncpu = 0 ;
14357
14358
#ifdef MS_WINDOWS
14358
14359
#ifdef MS_WINDOWS_DESKTOP
Original file line number Diff line number Diff line change @@ -1690,9 +1690,9 @@ config_read_env_vars(PyConfig *config)
1690
1690
static PyStatus
1691
1691
config_init_cpu_count (PyConfig * config )
1692
1692
{
1693
- int cpu_count = -1 ;
1694
1693
const char * env = config_get_env (config , "PYTHONCPUCOUNT" );
1695
1694
if (env ) {
1695
+ int cpu_count = -1 ;
1696
1696
if (_Py_str_to_int (env , & cpu_count ) != 0 ) {
1697
1697
cpu_count = -1 ;
1698
1698
}
@@ -1702,6 +1702,7 @@ config_init_cpu_count(PyConfig *config)
1702
1702
}
1703
1703
const wchar_t * xoption = config_get_xoption (config , L"cpu_count" );
1704
1704
if (xoption ) {
1705
+ int cpu_count = -1 ;
1705
1706
const wchar_t * sep = wcschr (xoption , L'=' );
1706
1707
if (sep ) {
1707
1708
if (config_wstr_to_int (sep + 1 , & cpu_count ) < 0 || cpu_count < 1 ) {
You can’t perform that action at this time.
0 commit comments