Skip to content

Commit

Permalink
Avoid hangs on many-core Windows machines (pylint-dev#7035)
Browse files Browse the repository at this point in the history
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 pylint-dev#6965

Note that this only avoids the issue if an explicit jobs count is not
passed in.

Co-authored-by: Daniël van Noord <13665637+DanielNoord@users.noreply.github.com>
  • Loading branch information
2 people authored and Pierre-Sassoulas committed Jun 29, 2022
1 parent 09992d1 commit 8044a2b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions doc/whatsnew/2/2.14/full.rst
Expand Up @@ -13,6 +13,11 @@ Release date: TBA

Closes #7006

* Fixed an issue where many-core Windows machines (>~60 logical processors) would hang when
using the default jobs count.

Closes #6965

What's New in Pylint 2.14.3?
----------------------------
Release date: 2022-06-18
Expand Down
3 changes: 2 additions & 1 deletion pylint/lint/base_options.py
Expand Up @@ -244,7 +244,8 @@ def _make_linter_options(linter: PyLinter) -> Options:
"short": "j",
"default": 1,
"help": "Use multiple processes to speed up Pylint. Specifying 0 will "
"auto-detect the number of processors available to use.",
"auto-detect the number of processors available to use, and will cap "
"the count on Windows to avoid hangs.",
},
),
(
Expand Down
3 changes: 3 additions & 0 deletions pylint/lint/run.py
Expand Up @@ -82,6 +82,9 @@ def _cpu_count() -> int:
cpu_count = multiprocessing.cpu_count()
else:
cpu_count = 1
if sys.platform == "win32":
# See also https://github.com/python/cpython/issues/94242
cpu_count = min(cpu_count, 56) # pragma: no cover
if cpu_share is not None:
return min(cpu_share, cpu_count)
return cpu_count
Expand Down

0 comments on commit 8044a2b

Please sign in to comment.