File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -439,7 +439,8 @@ process which created it.
439439 >>> def f(x):
440440 ... return x*x
441441 ...
442- >>> p.map(f, [1,2,3])
442+ >>> with p:
443+ ... p.map(f, [1,2,3])
443444 Process PoolWorker-1:
444445 Process PoolWorker-2:
445446 Process PoolWorker-3:
@@ -2127,6 +2128,16 @@ with the :class:`Pool` class.
21272128 Note that the methods of the pool object should only be called by
21282129 the process which created the pool.
21292130
2131+ .. warning ::
2132+ :class: `multiprocessing.pool ` objects have internal resources that need to be
2133+ properly managed (like any other resource) by using the pool as a context manager
2134+ or by calling :meth: `close ` and :meth: `terminate ` manually. Failure to do this
2135+ can lead to the process hanging on finalization.
2136+
2137+ Note that is **not correct ** to rely on the garbage colletor to destroy the pool
2138+ as CPython does not assure that the finalizer of the pool will be called
2139+ (see :meth: `object.__del__ ` for more information).
2140+
21302141 .. versionadded :: 3.2
21312142 *maxtasksperchild *
21322143
You can’t perform that action at this time.
0 commit comments