multiprocessing.Manager
Prev: multiprocessing.log_to_stderr | Up: multiprocessing | Next: multiprocessing.parent_process
Rel: multiprocessing.active_children, multiprocessing.allow_connection_pickling, multiprocessing.Array, multiprocessing.AuthenticationError
Ref: docs.python.org — multiprocessing.Manager
Tags: #public #python3 #stdlib #multiprocessing
Import
import multiprocessing
from multiprocessing import Manager
Signature & Overview
multiprocessing.Manager()
Returns a manager associated with a running server process The managers methods such as Lock(), Condition() and Queue() can be used to create shared objects.
Usage
import multiprocessing as mp
# Starts a background server process hosting shared dicts/lists/Queues:
# with mp.Manager() as mgr:
# shared = mgr.dict(count=0)
assert callable(mp.Manager)
Gotchas
- Always use
with mp.Manager() as mgr:so the manager server process shuts down cleanly. - In-place mutations on nested containers aren't tracked: Reassign
d["items"] = itemsafter mutating a nested list insidemgr.dict().
REPL Inspect
from multiprocessing import Manager
help(Manager)
Linked from
Related notes
- tuts/python3/stdlib_module/multiprocessing/log_to_stderr Linked here; links to this page; shared tags: #multiprocessing, #stdlib
- tuts/python3/stdlib_module/multiprocessing/parent_process 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