Skip to content

Commit 7c6f69b

Browse files
committed
Add Queue.ShutDown documentation.
+ add ``Queue.shutdown` method, + update ``Queue.get``and ``Queue.put`` methods + add versionadded to ``get``and ``put``
1 parent 5981aaf commit 7c6f69b

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

Doc/library/multiprocessing.rst

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -932,8 +932,7 @@ For an example of the usage of queues for interprocess communication see
932932
standard library's :mod:`queue` module are raised to signal timeouts.
933933

934934
:class:`Queue` implements all the methods of :class:`queue.Queue` except for
935-
:meth:`~queue.Queue.task_done`, :meth:`~queue.Queue.join`, and
936-
:meth:`~queue.Queue.shutdown`.
935+
:meth:`~queue.Queue.task_done`, :meth:`~queue.Queue.join`.
937936

938937
.. method:: qsize()
939938

@@ -970,6 +969,10 @@ For an example of the usage of queues for interprocess communication see
970969
If the queue is closed, :exc:`ValueError` is raised instead of
971970
:exc:`AssertionError`.
972971

972+
Can raise the :exc:`queue.ShutDown` when queue shuts down.
973+
974+
.. versionadded:: 3.16
975+
973976
.. method:: put_nowait(obj)
974977

975978
Equivalent to ``put(obj, False)``.
@@ -988,10 +991,25 @@ For an example of the usage of queues for interprocess communication see
988991
If the queue is closed, :exc:`ValueError` is raised instead of
989992
:exc:`OSError`.
990993

994+
Can raise the :exc:`queue.ShutDown` when queue shuts down and is empty.
995+
996+
.. versionadded:: 3.16
997+
991998
.. method:: get_nowait()
992999

9931000
Equivalent to ``get(False)``.
9941001

1002+
.. method:: shutdown([immediate])
1003+
1004+
Shuts down the queue. If optional args *immediate* is ``False``
1005+
(the default), all remaining items could be retrieve until queue is empty.
1006+
If optional args *immediate* is ``True``, all remaining items from the
1007+
queue are erased. When queue is empty, get an item raises
1008+
a :exc:`queue.ShutDown` exception. Adding a new item into the queue
1009+
also raises this same exception.
1010+
1011+
.. versionadded:: 3.16
1012+
9951013
:class:`multiprocessing.Queue` has a few additional methods not found in
9961014
:class:`queue.Queue`. These methods are usually unnecessary for most
9971015
code:

0 commit comments

Comments
 (0)