summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2011-02-25 22:07:43 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2011-02-25 22:07:43 (GMT)
commit0bd4deba383b1c7f05a4e0c94f1d4b96050a1308 (patch)
treefd95fcfc38af8fceb8e56409f63e4e2bd30e0c52 /Doc
parent4bc685752f9f1056545ab121db833a4a68dd794c (diff)
downloadcpython-0bd4deba383b1c7f05a4e0c94f1d4b96050a1308.zip
cpython-0bd4deba383b1c7f05a4e0c94f1d4b96050a1308.tar.gz
cpython-0bd4deba383b1c7f05a4e0c94f1d4b96050a1308.tar.bz2
Issue #6064: Add a `daemon` keyword argument to the threading.Thread
and multiprocessing.Process constructors in order to override the default behaviour of inheriting the daemonic property from the current thread/process.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/multiprocessing.rst12
-rw-r--r--Doc/library/threading.rst14
2 files changed, 21 insertions, 5 deletions
diff --git a/Doc/library/multiprocessing.rst b/Doc/library/multiprocessing.rst
index cc40a2a..9bdbf54 100644
--- a/Doc/library/multiprocessing.rst
+++ b/Doc/library/multiprocessing.rst
@@ -297,7 +297,7 @@ The :mod:`multiprocessing` package mostly replicates the API of the
:class:`Process` and exceptions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.. class:: Process([group[, target[, name[, args[, kwargs]]]]])
+.. class:: Process([group[, target[, name[, args[, kwargs]]]]], *, daemon=None)
Process objects represent activity that is run in a separate process. The
:class:`Process` class has equivalents of all the methods of
@@ -312,13 +312,19 @@ The :mod:`multiprocessing` package mostly replicates the API of the
:sub:`1`,N\ :sub:`2`,...,N\ :sub:`k` is a sequence of integers whose length
is determined by the *generation* of the process. *args* is the argument
tuple for the target invocation. *kwargs* is a dictionary of keyword
- arguments for the target invocation. By default, no arguments are passed to
- *target*.
+ arguments for the target invocation. If provided, the keyword-only *daemon* argument
+ sets the process :attr:`daemon` flag to ``True`` or ``False``. If ``None``
+ (the default), this flag will be inherited from the creating process.
+
+ By default, no arguments are passed to *target*.
If a subclass overrides the constructor, it must make sure it invokes the
base class constructor (:meth:`Process.__init__`) before doing anything else
to the process.
+ .. versionchanged:: 3.3
+ Added the *daemon* argument.
+
.. method:: run()
Method representing the process's activity.
diff --git a/Doc/library/threading.rst b/Doc/library/threading.rst
index 5f1b9bf..7d192b5 100644
--- a/Doc/library/threading.rst
+++ b/Doc/library/threading.rst
@@ -241,7 +241,7 @@ changed through the :attr:`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:`daemon` property.
+through the :attr:`daemon` property or the *daemon* constructor argument.
There is a "main thread" object; this corresponds to the initial thread of
control in the Python program. It is not a daemon thread.
@@ -254,7 +254,8 @@ daemonic, and cannot be :meth:`join`\ ed. They are never deleted, since it is
impossible to detect the termination of alien threads.
-.. class:: Thread(group=None, target=None, name=None, args=(), kwargs={})
+.. class:: Thread(group=None, target=None, name=None, args=(), kwargs={},
+ verbose=None, *, daemon=None)
This constructor should always be called with keyword arguments. Arguments
are:
@@ -273,10 +274,19 @@ impossible to detect the termination of alien threads.
*kwargs* is a dictionary of keyword arguments for the target invocation.
Defaults to ``{}``.
+ *verbose* is a flag used for debugging messages.
+
+ If not ``None``, *daemon* explicitly sets whether the thread is daemonic.
+ If ``None`` (the default), the daemonic property is inherited from the
+ current thread.
+
If the subclass overrides the constructor, it must make sure to invoke the
base class constructor (``Thread.__init__()``) before doing anything else to
the thread.
+ .. versionchanged:: 3.3
+ Added the *daemon* argument.
+
.. method:: start()
Start the thread's activity.