You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

wcpan-queue

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wcpan-queue

An utility for asyncio.Queue.

7.2.1
pipPyPI
Maintainers
1

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.

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts