On this page
multiprocessing.Queue
Prev: multiprocessing.ProcessError | Up: multiprocessing | Next: multiprocessing.RawArray
Rel: multiprocessing.active_children, multiprocessing.allow_connection_pickling, multiprocessing.Array, multiprocessing.AuthenticationError
Ref: docs.python.org — multiprocessing.Queue
Tags: #public #python3 #stdlib #multiprocessing
Import
import multiprocessing
from multiprocessing import Queue
Signature & Overview
multiprocessing.Queue(maxsize=0)
Returns a queue object
Usage
import multiprocessing as mp
q = mp.Queue()
q.put(42)
assert q.get(timeout=1) == 42
q.close()
q.join_thread()
Gotchas
- Drain the queue before
p.join(): A child process that wrote large data to aQueuecannot exit until the parent consumes it—joining first can deadlock. - Items must be picklable.
REPL Inspect
from multiprocessing import Queue
help(Queue)
Linked from
Related notes
- tuts/python3/stdlib_module/multiprocessing/ProcessError Linked here; links to this page; shared tags: #multiprocessing, #stdlib
- tuts/python3/stdlib_module/multiprocessing/RawArray Linked here; links to this page; shared tags: #multiprocessing, #stdlib
- tuts/python3/stdlib_module/multiprocessing Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/multiprocessing/active_children Linked here; shared tags: #multiprocessing, #stdlib
- tuts/python3/stdlib_module/multiprocessing/allow_connection_pickling Linked here; shared tags: #multiprocessing, #stdlib
- tuts/python3/stdlib_module/multiprocessing/Array Linked here; shared tags: #multiprocessing, #stdlib
- tuts/python3/stdlib_module/multiprocessing/AuthenticationError Linked here; shared tags: #multiprocessing, #stdlib
- tuts/python3/stdlib_module/multiprocessing/Barrier shared tags: #multiprocessing, #stdlib
- tuts/python3/stdlib_module/multiprocessing/BoundedSemaphore shared tags: #multiprocessing, #stdlib
- tuts/python3/stdlib_module/multiprocessing/BufferTooShort shared tags: #multiprocessing, #stdlib