QueuePlus ➕
1️⃣ version: 0.7.0
✍️ author: Mitchell Lisle
A Python library that adds functionality to asyncio queues
Install
pip install queueplus
Usage
You can use AioQueue with all the same functionality as a regular asyncio.Queue.
from queueplus import AioQueue
q = AioQueue()
await q.put("hello world")
message = await q.get()
# hello world
With a few extra capabilities
Iterate over a queue (can be async or not)
from queueplus import AioQueue
q = AioQueue()
[await q.put(i) for i in range(10)] # in non-async mode you would call q.put_nowait
async for row in q:
print(row)
Collect all values into a list
from queueplus import AioQueue
q = AioQueue()
[await q.put(i) for i in range(10)]
messages = q.collect()
# [0, 1, 2, 3, 4 ,5 ,6 ,7, 8, 9]
Create a callback everytime a message is added
from queueplus import AioQueue
inq = AioQueue()
outq = AioQueue()
async def copy_to_q(message: str):
await outq.put(message)
inq.add_consumer(copy_to_q)
inq.put("hello world")
await inq.wait_for_consumer()
Enforce a type on a queue, error if violated
from queueplus import TypedAioQueue, RaiseOnViolation
q = TypedAioQueue(int, violations_strategy=RaiseOnViolation)
[await q.put(i) for i in range(10)]
messages = q.collect()
# [0, 1, 2, 3, 4 ,5 ,6 ,7, 8, 9]
await q.put("hello") # Raises a ViolationError
Enforce a type on a queue, ignore if violated
from queueplus import TypedAioQueue, DiscardOnViolation
q = TypedAioQueue(int, violations_strategy=DiscardOnViolation)
[await q.put(i) for i in range(10)]
await q.put("hello")
messages = q.collect()
# [0, 1, 2, 3, 4 ,5 ,6 ,7, 8, 9]
Full example
from queueplus import AioQueue
import asyncio
async def main():
q = AioQueue()
await q.put("hello")
await q.put("world")
async for item in q:
print(item)
if __name__ == "__main__":
asyncio.run(main())
Metadata
Release files for queueplus 0.7.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| queueplus-0.7.0.tar.gz | 6.6 kB | Without provenance | Details for queueplus-0.7.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| queueplus-0.7.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for queueplus-0.7.0-py2.py3-none-any.whl |
Total release size: 11.1 kB
Release files / queueplus-0.7.0.tar.gz
| Download URL | queueplus-0.7.0.tar.gz |
|---|---|
| Size | 6.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0211ca5d9e01ea1434ff26ad2a8f179fe754f3c8e285949febf26d002b078e95
|
|
BLAKE2b-256 checksum How to use checksums |
5bfe340238fe2c0f9537d8768c5c9cd8e31de686e75d68bd68591019499e76b2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.1
|
Release files / queueplus-0.7.0-py2.py3-none-any.whl
| Download URL | queueplus-0.7.0-py2.py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
2686adcb173def742acd4c7d764f262b6897bb7f2a9542fd79ae83290e4213bb
|
|
BLAKE2b-256 checksum How to use checksums |
675cdc07bb9e7ed9160d416fed4bd335f80ae6db84930cf0524d1bd1e8183b47
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.1
|
Security for queueplus 0.7.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.