diff options
author | Jesse Noller <jnoller@gmail.com> | 2010-01-27 03:36:01 (GMT) |
---|---|---|
committer | Jesse Noller <jnoller@gmail.com> | 2010-01-27 03:36:01 (GMT) |
commit | 1f0b6586387a3dae59cf28239effe14f1333229a (patch) | |
tree | 5113af47512d196c433d6bcb695985bcbc21a14f /Doc | |
parent | c3511a461de4e7370415b7de85eb193b6ee1548a (diff) | |
download | cpython-1f0b6586387a3dae59cf28239effe14f1333229a.zip cpython-1f0b6586387a3dae59cf28239effe14f1333229a.tar.gz cpython-1f0b6586387a3dae59cf28239effe14f1333229a.tar.bz2 |
Merged revisions 77794 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77794 | jesse.noller | 2010-01-26 22:05:57 -0500 (Tue, 26 Jan 2010) | 1 line
Issue #6963: Added maxtasksperchild argument to multiprocessing.Pool
........
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/multiprocessing.rst | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/Doc/library/multiprocessing.rst b/Doc/library/multiprocessing.rst index a2cdb02..6d7e768 100644 --- a/Doc/library/multiprocessing.rst +++ b/Doc/library/multiprocessing.rst @@ -1535,7 +1535,7 @@ Process Pools One can create a pool of processes which will carry out tasks submitted to it with the :class:`Pool` class. -.. class:: multiprocessing.Pool([processes[, initializer[, initargs]]]) +.. class:: multiprocessing.Pool([processes[, initializer[, initargs[, maxtasksperchild]]]]) A process pool object which controls a pool of worker processes to which jobs can be submitted. It supports asynchronous results with timeouts and @@ -1546,6 +1546,21 @@ with the :class:`Pool` class. *initializer* is not ``None`` then each worker process will call ``initializer(*initargs)`` when it starts. + *maxtasksperchild* is the number of tasks a worker process can complete + before it will exit and be replaced with a fresh worker process, to enable + unused resources to be freed. The default *maxtasksperchild* is None, which + means worker processes will live as long as the pool. + + .. note:: + + Worker processes within a :class:`Pool` typically live for the complete + duration of the Pool's work queue. A frequent pattern found in other + systems (such as Apache, mod_wsgi, etc) to free resources held by + workers is to allow a worker within a pool to complete only a set + amount of work before being exiting, being cleaned up and a new + process spawned to replace the old one. The *maxtasksperchild* + argument to the :class:`Pool` exposes this ability to the end user. + .. method:: apply(func[, args[, kwds]]) Call *func* with arguments *args* and keyword arguments *kwds*. It blocks |