Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 11 additions & 3 deletions Lib/test/test_concurrent_futures.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ def my_method(self):


class EventfulGCObj():
def __init__(self, ctx):
mgr = get_context(ctx).Manager()
def __init__(self, mgr):
self.event = mgr.Event()

def __del__(self):
Expand Down Expand Up @@ -848,12 +847,21 @@ def test_traceback(self):
def test_ressources_gced_in_workers(self):
# Ensure that argument for a job are correctly gc-ed after the job
# is finished
obj = EventfulGCObj(self.ctx)
mgr = get_context(self.ctx).Manager()
obj = EventfulGCObj(mgr)
future = self.executor.submit(id, obj)
future.result()

self.assertTrue(obj.event.wait(timeout=1))

# explicitly destroy the object to ensure that EventfulGCObj.__del__()
# is called while manager is still running.
obj = None
test.support.gc_collect()

mgr.shutdown()
mgr.join()


create_executor_tests(ProcessPoolExecutorTest,
executor_mixins=(ProcessPoolForkMixin,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fix test_ressources_gced_in_workers() of test_concurrent_futures: explicitly
stop the manager to prevent leaking a child process running in the background
after the test completes.