]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #17208: add a note about the termination behaviour of daemon threads.
authorAntoine Pitrou <solipsis@pitrou.net>
Fri, 15 Feb 2013 20:31:33 +0000 (21:31 +0100)
committerAntoine Pitrou <solipsis@pitrou.net>
Fri, 15 Feb 2013 20:31:33 +0000 (21:31 +0100)
1  2 
Doc/library/threading.rst

index ec235046ce781024fb5ffc06b2779345bb2c1099,e30f0e354dae74f3756fdf295c400dd8eadbc506..00ae3ec095ea7a30b99a0bde0d631b0db538a5d6
@@@ -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.