summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-07-28 22:46:45 (GMT)
committerGitHub <noreply@github.com>2022-07-28 22:46:45 (GMT)
commitb50f58ecb4a15a004c83074276f079c982574732 (patch)
tree8c7f9bbce20a05a60f7de45ad7b29eb095b3760e
parent1368a1f724ebcab803644adbf764d8d30b18cfd0 (diff)
downloadcpython-b50f58ecb4a15a004c83074276f079c982574732.zip
cpython-b50f58ecb4a15a004c83074276f079c982574732.tar.gz
cpython-b50f58ecb4a15a004c83074276f079c982574732.tar.bz2
gh-86128: Add warning to ThreadPoolExecutor docs about atexit behaviour (GH-94008)
(cherry picked from commit 7df2f4d78714707cfb30d83ca99ce84ef9934892) Co-authored-by: [object Object] <lucas.wiman@gmail.com>
-rw-r--r--Doc/library/concurrent.futures.rst7
-rw-r--r--Misc/NEWS.d/next/Documentation/2022-06-19-18-18-22.gh-issue-86128.39DDTD.rst1
2 files changed, 8 insertions, 0 deletions
diff --git a/Doc/library/concurrent.futures.rst b/Doc/library/concurrent.futures.rst
index 8efbf0a..db5971e 100644
--- a/Doc/library/concurrent.futures.rst
+++ b/Doc/library/concurrent.futures.rst
@@ -149,6 +149,13 @@ And::
An :class:`Executor` subclass that uses a pool of at most *max_workers*
threads to execute calls asynchronously.
+ All threads enqueued to ``ThreadPoolExecutor`` will be joined before the
+ interpreter can exit. Note that the exit handler which does this is
+ executed *before* any exit handlers added using `atexit`. This means
+ exceptions in the main thread must be caught and handled in order to
+ signal threads to exit gracefully. For this reason, it is recommended
+ that ``ThreadPoolExecutor`` not be used for long-running tasks.
+
*initializer* is an optional callable that is called at the start of
each worker thread; *initargs* is a tuple of arguments passed to the
initializer. Should *initializer* raise an exception, all currently
diff --git a/Misc/NEWS.d/next/Documentation/2022-06-19-18-18-22.gh-issue-86128.39DDTD.rst b/Misc/NEWS.d/next/Documentation/2022-06-19-18-18-22.gh-issue-86128.39DDTD.rst
new file mode 100644
index 0000000..bab0068
--- /dev/null
+++ b/Misc/NEWS.d/next/Documentation/2022-06-19-18-18-22.gh-issue-86128.39DDTD.rst
@@ -0,0 +1 @@
+Document a limitation in ThreadPoolExecutor where its exit handler is executed before any handlers in atexit.