Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
bpo-19675: clean up and fix typos in test and NEWS
  • Loading branch information
taleinat committed Sep 10, 2018
commit f569cae4de8bba4cbf945d969150e061d7e6aeb2
16 changes: 7 additions & 9 deletions Lib/test/_test_multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -4608,7 +4608,7 @@ def test_release_unused_processes(self):
will_fail_in = 3
forked_processes = []

class FailingForkProcess():
class FailingForkProcess:
def __init__(self, **kwargs):
self.name = 'Fake Process'
self.exitcode = None
Expand All @@ -4618,27 +4618,25 @@ def __init__(self, **kwargs):
def start(self):
nonlocal will_fail_in
if will_fail_in <= 0:
raise OSError("Manually inducted OSError")
raise OSError("Manually induced OSError")
will_fail_in -= 1
self.state = 'started'

def terminate(self):
self.state = 'stopped'
self.state = 'stopping'

def join(self):
pass
if self.state == 'stopping':
self.state = 'stopped'

def is_alive(self):
return self.state == 'started'
return self.state == 'started' or self.state == 'stopping'

try:
with self.assertRaisesRegex(OSError, 'Manually induced OSError'):
p = multiprocessing.pool.Pool(5, context=unittest.mock.MagicMock(
Process=FailingForkProcess))
p.close()
p.join()
except OSError as err:
if str(err) != 'Manually inducted OSError':
raise
self.assertFalse(
any(process.is_alive() for process in forked_processes))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
multiprocessing.Pool does no longer leak processes if the construction of
the pool fails.
``multiprocessing.Pool`` no longer leaks processes if its initialization fails.