Skip to content

Commit db0b7be

Browse files
committed
Issue #17208: add a note about the termination behaviour of daemon threads.
2 parents 23e043f + 38b8254 commit db0b7be

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
@@ -174,6 +174,12 @@ initial value is inherited from the creating thread. The flag can be set
174174
through the :attr:`~Thread.daemon` property or the *daemon* constructor
175175
argument.
176176

177+
.. note::
178+
Daemon threads are abruptly stopped at shutdown. Their resources (such
179+
as open files, database transactions, etc.) may not be released properly.
180+
If you want your threads to stop gracefully, make them non-daemonic and
181+
use a suitable signalling mechanism such as an :class:`Event`.
182+
177183
There is a "main thread" object; this corresponds to the initial thread of
178184
control in the Python program. It is not a daemon thread.
179185

0 commit comments

Comments
 (0)