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

asyncio.BoundedSemaphore

Prev: asyncio.BaseTransport | Up: asyncio | Next: asyncio.BrokenBarrierError
Rel: asyncio.AbstractEventLoop, asyncio.AbstractServer, asyncio.all_tasks, asyncio.as_completed
Ref: docs.python.org — asyncio.BoundedSemaphore
Tags: #public #python3 #stdlib #asyncio


Import

import asyncio
from asyncio import BoundedSemaphore

Signature & Overview

asyncio.BoundedSemaphore(value=1)

A bounded semaphore implementation.

Methods & Attributes

Usage

import asyncio

async def main():
    sem = asyncio.BoundedSemaphore(2)
    async with sem:
        assert True

asyncio.run(main())

Gotchas

REPL Inspect

from asyncio import BoundedSemaphore
help(BoundedSemaphore)

Linked from

Related notes