Skip to content

Commit bee24cd

Browse files
randomasciiDanielNoord
authored andcommitted
Avoid hangs on many-core Windows machines (#7035)
Creating a multiprocessing Pool with too many processes can hit ValueError exceptions or hangs or both. The number that counts as "too many" depends on the Python version so this change uses 56 as a guaranteed safe limit. Details in #6965 Note that this only avoids the issue if an explicit jobs count is not passed in. Co-authored-by: Daniël van Noord <[email protected]>
1 parent b379ef3 commit bee24cd

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

doc/whatsnew/2/2.14/full.rst

+5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ Release date: TBA
1313

1414
Closes #7006
1515

16+
* Fixed an issue where many-core Windows machines (>~60 logical processors) would hang when
17+
using the default jobs count.
18+
19+
Closes #6965
20+
1621
What's New in Pylint 2.14.3?
1722
----------------------------
1823
Release date: 2022-06-18

pylint/lint/base_options.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ def _make_linter_options(linter: PyLinter) -> Options:
244244
"short": "j",
245245
"default": 1,
246246
"help": "Use multiple processes to speed up Pylint. Specifying 0 will "
247-
"auto-detect the number of processors available to use.",
247+
"auto-detect the number of processors available to use, and will cap "
248+
"the count on Windows to avoid hangs.",
248249
},
249250
),
250251
(

pylint/lint/run.py

+3
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ def _cpu_count() -> int:
8282
cpu_count = multiprocessing.cpu_count()
8383
else:
8484
cpu_count = 1
85+
if sys.platform == "win32":
86+
# See also https://github.com/python/cpython/issues/94242
87+
cpu_count = min(cpu_count, 56) # pragma: no cover
8588
if cpu_share is not None:
8689
return min(cpu_share, cpu_count)
8790
return cpu_count

0 commit comments

Comments
 (0)