Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 95fe1a7

Browse files
committed
Issue #18277: Document quirks of multiprocessing queue.
1 parent e0a2d12 commit 95fe1a7

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

Doc/library/multiprocessing.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,23 @@ Note that one can also create a shared queue by using a manager object -- see
515515
the :mod:`multiprocessing` namespace so you need to import them from
516516
:mod:`queue`.
517517

518+
.. note::
519+
520+
When an object is put on a queue, the object is pickled and a
521+
background thread later flushes the pickled data to an underlying
522+
pipe. This has some consequences which are a little surprising,
523+
but should not cause any pratical difficulties -- you can always
524+
use a managed queue if they really bother you.
525+
526+
(1) After putting an object on an empty queue there may be an
527+
infinitessimal delay before the queue's :meth:`~Queue.empty`
528+
method returns :const:`False` and :meth:`~Queue.get_nowait` can
529+
return without raising :exc:`Queue.Empty`.
530+
531+
(2) If multiple processes are enqueuing objects, it is possible for
532+
the objects to be received at the other end out-of-order.
533+
However, objects enqueued by the same process will always be in
534+
the expected order with respect to each other.
518535

519536
.. warning::
520537

0 commit comments

Comments
 (0)