On this page
multiprocessing.Pipe
Prev: multiprocessing.parent_process | Up: multiprocessing | Next: multiprocessing.Pool
Rel: multiprocessing.active_children, multiprocessing.allow_connection_pickling, multiprocessing.Array, multiprocessing.AuthenticationError
Ref: docs.python.org — multiprocessing.Pipe
Tags: #public #python3 #stdlib #multiprocessing
Import
import multiprocessing
from multiprocessing import Pipe
Signature & Overview
multiprocessing.Pipe(duplex=True)
Returns two connection object connected by a pipe
Usage
import multiprocessing as mp
left, right = mp.Pipe()
try:
left.send({"ok": True})
assert right.recv() == {"ok": True}
finally:
left.close(); right.close()
Gotchas
- Two-endpoint channel only: Two processes must NOT simultaneously read or write the same pipe endpoint—use
Queuefor multiple producers/consumers.
REPL Inspect
from multiprocessing import Pipe
help(Pipe)
Linked from
Related notes
- tuts/python3/stdlib_module/multiprocessing/parent_process Linked here; links to this page; shared tags: #multiprocessing, #stdlib
- tuts/python3/stdlib_module/multiprocessing/Pool 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