Issue #15064: Implement context manager protocol for multiprocessing types
diff --git a/Doc/library/multiprocessing.rst b/Doc/library/multiprocessing.rst
index 4171977..2f64bb1 100644
--- a/Doc/library/multiprocessing.rst
+++ b/Doc/library/multiprocessing.rst
@@ -834,6 +834,10 @@
Connection objects themselves can now be transferred between processes
using :meth:`Connection.send` and :meth:`Connection.recv`.
+ .. versionadded:: 3.3
+ Connection objects now support the context manager protocol -- see
+ :ref:`typecontextmanager`. :meth:`__enter__` returns the
+ connection object, and :meth:`__exit__` calls :meth:`close`.
For example:
@@ -1277,6 +1281,9 @@
The address used by the manager.
+ Manager objects support the context manager protocol -- see
+ :ref:`typecontextmanager`. :meth:`__enter__` returns the
+ manager object, and :meth:`__exit__` calls :meth:`shutdown`.
.. class:: SyncManager
@@ -1747,6 +1754,11 @@
Wait for the worker processes to exit. One must call :meth:`close` or
:meth:`terminate` before using :meth:`join`.
+ .. versionadded:: 3.3
+ Pool objects now support the context manager protocol -- see
+ :ref:`typecontextmanager`. :meth:`__enter__` returns the pool
+ object, and :meth:`__exit__` calls :meth:`terminate`.
+
.. class:: AsyncResult
@@ -1911,6 +1923,11 @@
The address from which the last accepted connection came. If this is
unavailable then it is ``None``.
+ .. versionadded:: 3.3
+ Listener objects now support the context manager protocol -- see
+ :ref:`typecontextmanager`. :meth:`__enter__` returns the
+ listener object, and :meth:`__exit__` calls :meth:`close`.
+
.. function:: wait(object_list, timeout=None)
Wait till an object in *object_list* is ready. Returns the list of