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.1.tar.gz
(3.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wcpan_queue-7.2.1.tar.gz.
File metadata
- Download URL: wcpan_queue-7.2.1.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c04e3bb3b9eb1ceb1d2b2df8ed5fa5ae53a7e47375c9d5eee9a27a2ea269ed46
|
|
| MD5 |
813bbcd5aebf2ba7b055136984a65aea
|
|
| BLAKE2b-256 |
2e70c19a6317cd4c913c4c3fedb26a819d82982ab1c9e3e8a52c776c7e4e08e9
|
File details
Details for the file wcpan_queue-7.2.1-py3-none-any.whl.
File metadata
- Download URL: wcpan_queue-7.2.1-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1688ac9727ad943d88972cc5cc591918e344fd499893f7f81cb264fc6489eba9
|
|
| MD5 |
b0392c693ac77a4828fa93c075301eef
|
|
| BLAKE2b-256 |
e673ec674e250715a2c0a3f08f4e2864032b15e1a69809c73b05a5c3364e2534
|