Skip to content

Commit 70cdb9d

Browse files
authored
Merge pull request #3869 from manderj/pytest_pylint_parallel_runs_warnings
lint multiprocessing pool shutdown
2 parents 34d6fcb + 136ab0f commit 70cdb9d

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

CONTRIBUTORS.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,3 +425,5 @@ contributors:
425425
* Giuseppe Valente: contributor
426426

427427
* Takashi Hirashima: contributor
428+
429+
* Joffrey Mander: contributor

ChangeLog

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ What's New in Pylint 2.6.1?
1515
===========================
1616
Release date: TBA
1717

18+
* Fix linter multiprocessing pool shutdown (triggered warnings when runned in parallels with other pytest plugins)
19+
20+
Closes #3779
21+
1822
* Fix a false-positive emission of `no-self-use` and `unused-argument` for methods
1923
of generic structural types (`Protocol[T]`)
2024

@@ -23,7 +27,7 @@ Release date: TBA
2327
* Fix bug that lead to duplicate messages when using ``--jobs 2`` or more.
2428

2529
Close #3584
26-
30+
2731
* Adds option ``check-protected-access-in-special-methods`` in the ClassChecker to activate/deactivate
2832
``protected-access`` message emission for single underscore prefixed attribute in special methods.
2933

doc/whatsnew/2.6.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ New checkers
2929
Other Changes
3030
=============
3131

32+
* Fix linter multiprocessing pool shutdown which triggered warnings when runned in parallels with other pytest plugins.
33+
3234
* Enums are now required to be named in UPPER_CASE by ``invalid-name``.
3335

3436
* Fix bug that lead to duplicate messages when using ``--jobs 2`` or more.

pylint/lint/parallel.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,16 @@ def check_parallel(linter, jobs, files, arguments=None):
9191
# is identical to the linter object here. This is requred so that
9292
# a custom PyLinter object can be used.
9393
initializer = functools.partial(_worker_initialize, arguments=arguments)
94-
with multiprocessing.Pool(jobs, initializer=initializer, initargs=[linter]) as pool:
95-
# ..and now when the workers have inherited the linter, the actual reporter
96-
# can be set back here on the parent process so that results get stored into
97-
# correct reporter
98-
linter.set_reporter(original_reporter)
99-
linter.open()
94+
pool = multiprocessing.Pool(jobs, initializer=initializer, initargs=[linter])
95+
# ..and now when the workers have inherited the linter, the actual reporter
96+
# can be set back here on the parent process so that results get stored into
97+
# correct reporter
98+
linter.set_reporter(original_reporter)
99+
linter.open()
100100

101-
all_stats = []
101+
all_stats = []
102102

103+
try:
103104
for (
104105
module,
105106
file_path,
@@ -116,6 +117,9 @@ def check_parallel(linter, jobs, files, arguments=None):
116117

117118
all_stats.append(stats)
118119
linter.msg_status |= msg_status
120+
finally:
121+
pool.close()
122+
pool.join()
119123

120124
linter.stats = _merge_stats(all_stats)
121125

0 commit comments

Comments
 (0)