Asyncio queues with extended functionality: peeking, setting put and get callbacks.
Project description
aioqueueext
A package that provides asyncio Queues with additional functionality.
Work-in-Progress
The repository contains modules extracted from my other project and was refactored as a separate package.
In the current version, I have not verified all of the functions.
Additional functions I plan to implement are:
return_when_*()- async functions to ease synchronization tasksset_on_get_callback()set_on_put_callback()peek_nowait()- returns the "up-next" item without removing it from the queuepeek_and_get()- async peek and conditionally get (pop) an item from the queue
Examples
Sync Peeking
async def sync_peeking_example() -> None:
queue1 = QueueExt()
await queue1.put("apple")
item = queue1.peek_nowait()
print(f"first peek: {item}") # "apple"
await queue1.put("banana")
item = queue1.peek_nowait()
print(f"second peek: {item}") # "apple"
item = await queue1.get() # popped "apple"
item = queue1.peek_nowait()
print(f"third peek: {item}") # "banana"
item = await queue1.get() # popped "banana"
# the next peek raises the QueueEmpty exception
try:
print(f"fourth peek: {queue1.peek_nowait()}")
except asyncio.QueueEmpty:
print("fourth peek failed: QueueEmpty")
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
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 aioqueueext-0.2.1.tar.gz.
File metadata
- Download URL: aioqueueext-0.2.1.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce56ed86e88219437ed7cc072de5f0c3758c1a0e3024423e2add4bdd0834786e
|
|
| MD5 |
37a1ce1e8064274f8ae8f6de21bb9c34
|
|
| BLAKE2b-256 |
275f7fcafafcfb3528a5265c3d72560b1b9fc6d411df0d18286ce76eab44c148
|
File details
Details for the file aioqueueext-0.2.1-py3-none-any.whl.
File metadata
- Download URL: aioqueueext-0.2.1-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20ef95a2951482df38b742876c0ef1c769ec071d7aee1c5fbfbcc28456d28e2c
|
|
| MD5 |
c88a807d29aa7b2d8aa773e156155dda
|
|
| BLAKE2b-256 |
f6424ab0f3050a2b7799779c278dde3b56d6e98f4e360f8b2572fba65268a4d2
|