Skip to content

Commit c2c7fee

Browse files
committed
Add put / get document
1 parent 612d8ac commit c2c7fee

1 file changed

Lines changed: 32 additions & 2 deletions

File tree

‎Doc/library/concurrent.interpreters.rst‎

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,17 +349,47 @@ Communicating Between Interpreters
349349

350350
Return ``True`` if the queue is full, ``False`` otherwise.
351351

352+
.. method:: put(obj, block=True, timeout=None)
353+
354+
Put *obj* into the queue. If optional args *block* is true and
355+
*timeout* is ``None`` (the default), block if necessary until a free
356+
slot is available. If *timeout* is a positive number, it blocks at
357+
most *timeout* seconds and raises the :exc:`QueueFull` exception if
358+
no free slot was available within that time. Otherwise (*block* is
359+
false), put an object on the queue if a free slot is immediately
360+
available, else raise the :exc:`QueueFull` exception (*timeout* is
361+
ignored in that case).
362+
363+
.. method:: put_nowait(obj)
364+
365+
Equivalent to ``put(obj, block=False)``.
366+
367+
.. method:: get(block=True, timeout=None)
368+
369+
Remove and return an object from the queue. If optional args *block*
370+
is true and *timeout* is ``None`` (the default), block if necessary
371+
until an object is available. If *timeout* is a positive number, it
372+
blocks at most *timeout* seconds and raises the :exc:`QueueEmpty`
373+
exception if no object was available within that time. Otherwise
374+
(*block* is false), return an object if one is immediately available,
375+
else raise the :exc:`QueueEmpty` exception (*timeout* is ignored in
376+
that case).
377+
378+
.. method:: get_nowait()
379+
380+
Equivalent to ``get(block=False)``.
381+
352382

353383
.. exception:: QueueEmpty
354384

355385
This exception, a subclass of :exc:`queue.Empty`, is raised from
356-
:meth:`!Queue.get` and :meth:`!Queue.get_nowait` when the queue
386+
:meth:`Queue.get` and :meth:`Queue.get_nowait` when the queue
357387
is empty.
358388

359389
.. exception:: QueueFull
360390

361391
This exception, a subclass of :exc:`queue.Full`, is raised from
362-
:meth:`!Queue.put` and :meth:`!Queue.put_nowait` when the queue
392+
:meth:`Queue.put` and :meth:`Queue.put_nowait` when the queue
363393
is full.
364394

365395

0 commit comments

Comments
 (0)