]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-86128: Add warning to ThreadPoolExecutor docs about atexit behaviour (GH-94008)
author[object Object] <lucas.wiman@gmail.com>
Thu, 28 Jul 2022 22:38:56 +0000 (15:38 -0700)
committerGitHub <noreply@github.com>
Thu, 28 Jul 2022 22:38:56 +0000 (23:38 +0100)
Doc/library/concurrent.futures.rst
Misc/NEWS.d/next/Documentation/2022-06-19-18-18-22.gh-issue-86128.39DDTD.rst [new file with mode: 0644]

index 8efbf0a3d59554320fd076d3352bb4324797d4a6..db5971e4d60fc9dcdbc95a0dbb2144f2e1b04128 100644 (file)
@@ -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 (file)
index 0000000..bab0068
--- /dev/null
@@ -0,0 +1 @@
+Document a limitation in ThreadPoolExecutor where its exit handler is executed before any handlers in atexit.