File tree 2 files changed +6
-10
lines changed
2 files changed +6
-10
lines changed Original file line number Diff line number Diff line change @@ -133,11 +133,10 @@ def check_parallel(
133
133
# is identical to the linter object here. This is required so that
134
134
# a custom PyLinter object can be used.
135
135
initializer = functools .partial (_worker_initialize , arguments = arguments )
136
- pool = multiprocessing .Pool ( # pylint: disable=consider-using-with
136
+ with multiprocessing .Pool (
137
137
jobs , initializer = initializer , initargs = [dill .dumps (linter )]
138
- )
139
- linter .open ()
140
- try :
138
+ ) as pool :
139
+ linter .open ()
141
140
all_stats = []
142
141
all_mapreduce_data = collections .defaultdict (list )
143
142
@@ -164,9 +163,6 @@ def check_parallel(
164
163
all_stats .append (stats )
165
164
all_mapreduce_data [worker_idx ].append (mapreduce_data )
166
165
linter .msg_status |= msg_status
167
- finally :
168
- pool .close ()
169
- pool .join ()
170
166
171
167
_merge_mapreduce_data (linter , all_mapreduce_data )
172
168
linter .stats = merge_stats ([linter .stats ] + all_stats )
Original file line number Diff line number Diff line change @@ -189,10 +189,10 @@ def test_worker_initialize_pickling(self) -> None:
189
189
"""
190
190
linter = PyLinter (reporter = Reporter ())
191
191
linter .attribute = argparse .ArgumentParser () # type: ignore[attr-defined]
192
- pool = multiprocessing .Pool ( # pylint: disable=consider-using-with
192
+ with multiprocessing .Pool (
193
193
2 , initializer = worker_initialize , initargs = [dill .dumps (linter )]
194
- )
195
- pool .imap_unordered (print , [1 , 2 ])
194
+ ) as pool :
195
+ pool .imap_unordered (print , [1 , 2 ])
196
196
197
197
def test_worker_check_single_file_uninitialised (self ) -> None :
198
198
pylint .lint .parallel ._worker_linter = None
You can’t perform that action at this time.
0 commit comments