From: Antoine Pitrou Date: Fri, 15 Feb 2013 20:31:33 +0000 (+0100) Subject: Issue #17208: add a note about the termination behaviour of daemon threads. X-Git-Tag: v3.3.1rc1~172 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=db0b7be566f9442f8d09548b4ae1e4d475e09fc0;p=thirdparty%2FPython%2Fcpython.git Issue #17208: add a note about the termination behaviour of daemon threads. --- db0b7be566f9442f8d09548b4ae1e4d475e09fc0 diff --cc Doc/library/threading.rst index ec235046ce78,e30f0e354dae..00ae3ec095ea --- a/Doc/library/threading.rst +++ b/Doc/library/threading.rst @@@ -168,12 -239,17 +168,18 @@@ called is terminated A thread has a name. The name can be passed to the constructor, and read or changed through the :attr:`~Thread.name` attribute. -A thread can be flagged as a "daemon thread". The significance of this flag -is that the entire Python program exits when only daemon threads are left. -The initial value is inherited from the creating thread. The flag can be -set through the :attr:`~Thread.daemon` property. +A thread can be flagged as a "daemon thread". The significance of this flag is +that the entire Python program exits when only daemon threads are left. The +initial value is inherited from the creating thread. The flag can be set +through the :attr:`~Thread.daemon` property or the *daemon* constructor +argument. + .. note:: + Daemon threads are abruptly stopped at shutdown. Their resources (such + as open files, database transactions, etc.) may not be released properly. + If you want your threads to stop gracefully, make them non-daemonic and + use a suitable signalling mechanism such as an :class:`Event`. + There is a "main thread" object; this corresponds to the initial thread of control in the Python program. It is not a daemon thread.