On this page
  1. threading.Semaphore
  2. Import
  3. Signature & Overview
  4. Methods & Attributes
  5. Usage
  6. Gotchas
  7. REPL Inspect

threading.Semaphore

Prev: threading.RLock | Up: threading | Next: threading.setprofile
Rel: threading.active_count, threading.Barrier, threading.BoundedSemaphore, threading.BrokenBarrierError
Ref: docs.python.org โ€” threading.Semaphore
Tags: #public #python3 #stdlib #threading


Import

import threading
from threading import Semaphore

Signature & Overview

threading.Semaphore(value=1)

This class implements semaphore objects.

Methods & Attributes

Usage

import threading

pool_limit = threading.Semaphore(2)
with pool_limit:
    assert True

Gotchas

REPL Inspect

from threading import Semaphore
help(Semaphore)

Linked from

Related notes