Move all uses of pool inside run_parallel().

This includes creating the pool, tearing it down under normal use, and
tearing it down in case of exception.

Doing this makes it harder to leak processes, as for instance was
happening in #410.

Fixes #410
This commit is contained in:
Craig Silverstein 2018-03-02 20:49:31 -08:00
parent f834499726
commit a5573fc864
3 changed files with 34 additions and 34 deletions

View file

@ -22,17 +22,19 @@ def test_oserrors_cause_serial_fall_back():
style_guide = style_guide_mock()
with mock.patch('_multiprocessing.SemLock', side_effect=err):
manager = checker.Manager(style_guide, [], [])
manager.run()
assert manager.using_multiprocessing is False
@mock.patch('flake8.utils.is_windows', return_value=False)
def test_oserrors_are_reraised(is_windows):
"""Verify that OSErrors will cause the Manager to fallback to serial."""
"""Verify that unexpected OSErrors will cause the Manager to reraise."""
err = OSError(errno.EAGAIN, 'Ominous message')
style_guide = style_guide_mock()
with mock.patch('_multiprocessing.SemLock', side_effect=err):
with pytest.raises(OSError):
checker.Manager(style_guide, [], [])
manager = checker.Manager(style_guide, [], [])
manager.run()
def test_multiprocessing_is_disabled():