Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a7b8149

Browse files
committed
Issue #17208: add a note about the termination behaviour of daemon threads.
2 parents 10f8932 + db0b7be commit a7b8149

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
@@ -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)