Skip to content

Commit 196523f

Browse files
gh-86128: Add warning to ThreadPoolExecutor docs about atexit behaviour (GH-94008)
(cherry picked from commit 7df2f4d) Co-authored-by: [object Object] <lucas.wiman@gmail.com>
1 parent 4513e4a commit 196523f

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

Doc/library/concurrent.futures.rst

+7
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,13 @@ And::
149149
An :class:`Executor` subclass that uses a pool of at most *max_workers*
150150
threads to execute calls asynchronously.
151151

152+
All threads enqueued to ``ThreadPoolExecutor`` will be joined before the
153+
interpreter can exit. Note that the exit handler which does this is
154+
executed *before* any exit handlers added using `atexit`. This means
155+
exceptions in the main thread must be caught and handled in order to
156+
signal threads to exit gracefully. For this reason, it is recommended
157+
that ``ThreadPoolExecutor`` not be used for long-running tasks.
158+
152159
*initializer* is an optional callable that is called at the start of
153160
each worker thread; *initargs* is a tuple of arguments passed to the
154161
initializer. Should *initializer* raise an exception, all currently
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Document a limitation in ThreadPoolExecutor where its exit handler is executed before any handlers in atexit.

0 commit comments

Comments
 (0)