Skip to content

Commit 9fc6279

Browse files
committed
Issue #17208: add a note about the termination behaviour of daemon threads.
1 parent eae8100 commit 9fc6279

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

Doc/library/threading.rst

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

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

0 commit comments

Comments
 (0)