Skip to content

Commit

Permalink
Merge pull request #3869 from manderj/pytest_pylint_parallel_runs_war…
Browse files Browse the repository at this point in the history
…nings

lint multiprocessing pool shutdown
  • Loading branch information
hippo91 authored Oct 31, 2020
2 parents 34d6fcb + 136ab0f commit 70cdb9d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -425,3 +425,5 @@ contributors:
* Giuseppe Valente: contributor

* Takashi Hirashima: contributor

* Joffrey Mander: contributor
6 changes: 5 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ What's New in Pylint 2.6.1?
===========================
Release date: TBA

* Fix linter multiprocessing pool shutdown (triggered warnings when runned in parallels with other pytest plugins)

Closes #3779

* Fix a false-positive emission of `no-self-use` and `unused-argument` for methods
of generic structural types (`Protocol[T]`)

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

Close #3584

* Adds option ``check-protected-access-in-special-methods`` in the ClassChecker to activate/deactivate
``protected-access`` message emission for single underscore prefixed attribute in special methods.

Expand Down
2 changes: 2 additions & 0 deletions doc/whatsnew/2.6.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ New checkers
Other Changes
=============

* Fix linter multiprocessing pool shutdown which triggered warnings when runned in parallels with other pytest plugins.

* Enums are now required to be named in UPPER_CASE by ``invalid-name``.

* Fix bug that lead to duplicate messages when using ``--jobs 2`` or more.
Expand Down
18 changes: 11 additions & 7 deletions pylint/lint/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,16 @@ def check_parallel(linter, jobs, files, arguments=None):
# is identical to the linter object here. This is requred so that
# a custom PyLinter object can be used.
initializer = functools.partial(_worker_initialize, arguments=arguments)
with multiprocessing.Pool(jobs, initializer=initializer, initargs=[linter]) as pool:
# ..and now when the workers have inherited the linter, the actual reporter
# can be set back here on the parent process so that results get stored into
# correct reporter
linter.set_reporter(original_reporter)
linter.open()
pool = multiprocessing.Pool(jobs, initializer=initializer, initargs=[linter])
# ..and now when the workers have inherited the linter, the actual reporter
# can be set back here on the parent process so that results get stored into
# correct reporter
linter.set_reporter(original_reporter)
linter.open()

all_stats = []
all_stats = []

try:
for (
module,
file_path,
Expand All @@ -116,6 +117,9 @@ def check_parallel(linter, jobs, files, arguments=None):

all_stats.append(stats)
linter.msg_status |= msg_status
finally:
pool.close()
pool.join()

linter.stats = _merge_stats(all_stats)

Expand Down

0 comments on commit 70cdb9d

Please sign in to comment.