Skip to content

Commit 3844054

Browse files
miss-islingtonYashp002picnixz
authored
[3.14] gh-141617: clarify concurrent.futures.ThreadPoolExecutor deadlock example (GH-141620) (#145686)
gh-141617: clarify `concurrent.futures.ThreadPoolExecutor` deadlock example (GH-141620) --------- (cherry picked from commit 171133a) Co-authored-by: Yashraj <yashrajpala8@gmail.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
1 parent 778ff23 commit 3844054

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Doc/library/concurrent.futures.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,9 @@ And::
156156
print(f.result())
157157

158158
executor = ThreadPoolExecutor(max_workers=1)
159-
executor.submit(wait_on_future)
159+
future = executor.submit(wait_on_future)
160+
# Note: calling future.result() would also cause a deadlock because
161+
# the single worker thread is already waiting for wait_on_future().
160162

161163

162164
.. class:: ThreadPoolExecutor(max_workers=None, thread_name_prefix='', initializer=None, initargs=())

0 commit comments

Comments
 (0)