multiprocessing.Semaphore
Prev: multiprocessing.RLock | Up: multiprocessing | Next: multiprocessing.set_executable
Rel: multiprocessing.active_children, multiprocessing.allow_connection_pickling, multiprocessing.Array, multiprocessing.AuthenticationError
Ref: docs.python.org — multiprocessing.Semaphore
Tags: #public #python3 #stdlib #multiprocessing
Import
import multiprocessing
from multiprocessing import Semaphore
Signature & Overview
multiprocessing.Semaphore(value=1)
Returns a semaphore object
Usage
import multiprocessing as mp
sem = mp.Semaphore(3)
with sem:
assert True
Gotchas
- Prefer
BoundedSemaphorefor fixed resource pools so accidental extra.release()calls raiseValueError.
REPL Inspect
from multiprocessing import Semaphore
help(Semaphore)
Linked from
Related notes
- tuts/python3/stdlib_module/multiprocessing/RLock Linked here; links to this page; shared tags: #multiprocessing, #stdlib
- tuts/python3/stdlib_module/multiprocessing/set_executable 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