Skip to content

Commit 38d8c98

Browse files
committed
TST non regression test for python#6084
1 parent 44f70fd commit 38d8c98

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Lib/test/test_concurrent_futures.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,32 @@ def test_shutdown_deadlock(self):
10271027
with self.assertRaises(BrokenProcessPool):
10281028
f.result()
10291029

1030+
def test_shutdown_deadlock_pickle(self):
1031+
# Test that the pool calling shutdown with wait=False does not cause
1032+
# a deadlock if a task fails at pickle after the shutdown call.
1033+
# Reported in GH#6034.
1034+
self.executor.shutdown(wait=True)
1035+
with self.executor_type(max_workers=2,
1036+
mp_context=get_context(self.ctx)) as executor:
1037+
self.executor = executor # Allow clean up in fail_on_deadlock
1038+
1039+
# Start the executor and get the queue_management_thread to collect
1040+
# the threads and avoid dangling thread that should be cleaned up
1041+
# asynchronously.
1042+
executor.submit(id, 42).result()
1043+
queue_manager = executor._queue_management_thread
1044+
1045+
# Submit a task that fails at pickle and shutdown the executor
1046+
# without waiting
1047+
f = executor.submit(id, ErrorAtPickle())
1048+
executor.shutdown(wait=False)
1049+
with self.assertRaises(PicklingError):
1050+
f.result()
1051+
1052+
# Make sure the executor is eventually shutdown and do not leave
1053+
# dangling threads
1054+
queue_manager.join()
1055+
10301056

10311057
create_executor_tests(ExecutorDeadlockTest,
10321058
executor_mixins=(ProcessPoolForkMixin,

0 commit comments

Comments
 (0)