Skip to main content

An utility for asyncio.Queue.

Project description

wcpan.queue

An utility for asyncio.Queue.

Example

from wcpan.queue import AioQueue


async def task() -> int:
    ...


async def amain():
    # Creates a priority queue.
    # Use AioQueue.fifo() for FIFO and AioQueue.lifo() for LIFO.
    with AioQueue[int].priority() as queue:
        # Push a task which priority is 1, lesser number has higher priority.
        # Default is 0.
        # Priority is ignored for FIFO and LIFO queues.
        await queue.push(task(), 1)

        # Spawns 8 consumers to consume the queue.
        # The default is 1.
        await queue.consume(8)

        await queue.push(task())

        # Or collect the results like this:
        async for result in queue.collect(8):
            ...

        # If any error occurs, the context manager will cleanup all coroutines.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wcpan_queue-7.2.0.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wcpan_queue-7.2.0-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file wcpan_queue-7.2.0.tar.gz.

File metadata

  • Download URL: wcpan_queue-7.2.0.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.2 Linux/5.15.133.1-microsoft-standard-WSL2

File hashes

Hashes for wcpan_queue-7.2.0.tar.gz
Algorithm Hash digest
SHA256 5c374f2c34b56325b0a49ce66f04c6dd39f2d825683b6d56386649f2a730019a
MD5 028f7dd1c4c72b1460a7eefa67b5000c
BLAKE2b-256 7af89177bc81d1f1b3be9be580916a81eb25b657a7a2f5398395a1947eb655b7

See more details on using hashes here.

File details

Details for the file wcpan_queue-7.2.0-py3-none-any.whl.

File metadata

  • Download URL: wcpan_queue-7.2.0-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.2 Linux/5.15.133.1-microsoft-standard-WSL2

File hashes

Hashes for wcpan_queue-7.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f620902d5ffd979b3e638a7cc6f79907b75c20088011b3e014a562765880414d
MD5 586bea5a5754d00ab595670c856f52ec
BLAKE2b-256 89065dac226286d3ce601086b014addbaafa9beff85875bdcaffc3db3909a942

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page