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 @@ -429,7 +429,8 @@ process which created it.
429
429
>>> def f(x):
430
430
... return x*x
431
431
...
432
- >>> p.map(f, [1,2,3])
432
+ >>> with p:
433
+ ... p.map(f, [1,2,3])
433
434
Process PoolWorker-1:
434
435
Process PoolWorker-2:
435
436
Process PoolWorker-3:
@@ -2100,6 +2101,16 @@ with the :class:`Pool` class.
2100
2101
Note that the methods of the pool object should only be called by
2101
2102
the process which created the pool.
2102
2103
2104
+ .. warning ::
2105
+ :class: `multiprocessing.pool ` objects have internal resources that need to be
2106
+ properly managed (like any other resource) by using the pool as a context manager
2107
+ or by calling :meth: `close ` and :meth: `terminate ` manually. Failure to do this
2108
+ can lead to the process hanging on finalization.
2109
+
2110
+ Note that is **not correct ** to rely on the garbage colletor to destroy the pool
2111
+ as CPython does not assure that the finalizer of the pool will be called
2112
+ (see :meth: `object.__del__ ` for more information).
2113
+
2103
2114
.. versionadded :: 3.2
2104
2115
*maxtasksperchild *
2105
2116
You can’t perform that action at this time.
0 commit comments