Skip to content

Commit 38b8254

Browse files
committed
Issue #17208: add a note about the termination behaviour of daemon threads.
1 parent 439bdb1 commit 38b8254

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Doc/library/threading.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,12 @@ is that the entire Python program exits when only daemon threads are left.
244244
The initial value is inherited from the creating thread. The flag can be
245245
set through the :attr:`~Thread.daemon` property.
246246

247+
.. note::
248+
Daemon threads are abruptly stopped at shutdown. Their resources (such
249+
as open files, database transactions, etc.) may not be released properly.
250+
If you want your threads to stop gracefully, make them non-daemonic and
251+
use a suitable signalling mechanism such as an :class:`Event`.
252+
247253
There is a "main thread" object; this corresponds to the initial thread of
248254
control in the Python program. It is not a daemon thread.
249255

0 commit comments

Comments
 (0)