Handy Python Queue utilies
Project description
Queutils
Queutils [Queue Utils] is a package of handy Python queue classes:
- AsyncQueue - An
async
wrapper for non-asyncqueue.Queue
- IterableQueue - An
AsyncIterable
queue that terminates when finished - FileQueue - Builds an iterable queue of filenames from files/dirs given as input
AsyncQueue
AsyncQueue
is a async wrapper for non-async queue.Queue
. It can be used to create
an asyncio.Queue
compatible interface to a (non-async) managed multiprocessing.Queue
and thus enable async
code in parent/child processes to communicate over multiprocessing.Queue
as it were an asyncio.Queue
.
Features
asyncio.Queue
compatiblequeue.Queue
supportmultiprocessing.Queue
support
IterableQueue
IterableQueue
is an asyncio.Queue
subclass that is AsyncIterable[T]
i.e. it can be
iterated in async for
loop. IterableQueue
terminates automatically when the queue has been filled and emptied.
The IterableQueue
requires "producers" (functions adding items to the queue) to register themselves and it
keeps count of registered producers which are "finished" adding items to the queue. Once all the registered
producers are "finished", the queue enters into "filled" state and no new items can be added. Once an
"filled" queue is emptied, the queue becomes "done" and all new get()
calls to the queue will
raise QueueDone
exception.
Features
asyncio.Queue
interface,_nowait()
methods are experimentalAsyncIterable
support:async for item in queue:
- Automatic termination of the consumers with
QueueDone
exception when the queue has been emptied - Producers must be registered with
add_producer()
and they must notify the queue withfinish()
once they have finished adding items - Countable interface to count number of items task_done() through
count
property - Countable property can be disabled with count_items=False. This is useful when you want to sum the count of multiple IterableQueues
FileQueue
FileQueue
builds a queue (IterableQueue[pathlib.Path]
) of the matching
files found based on search parameters given. It can search both list of files or directories or
mixed. Async method FileQueue.mk_queue()
searches subdirectories of given directories.
Features
- Input can be given both as
str
andpathlib.Path
exclude: bool
exclusive or inclusive filtering. Default isFalse
.case_sensitive: bool
case sensitive filtering (use offnmatch
orfnmatchcase
). Default isTrue
.follow_symlinks: bool
whether to follow symlinks. Default isFalse
.
Project details
Release history Release notifications | RSS feed
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
File details
Details for the file queutils-0.8.4.tar.gz
.
File metadata
- Download URL: queutils-0.8.4.tar.gz
- Upload date:
- Size: 15.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6206a824df2fcddd9af6a1bcc827cab02bae5cc9beda74d6e3601d942d90c6df |
|
MD5 | 2ce9251d1ed9a5bc0cc0357b71862b98 |
|
BLAKE2b-256 | 99ba0300419868f98fea72cd3f17edf63ee954771b90c71fc5cf4a77e3bb08dc |
File details
Details for the file queutils-0.8.4-py3-none-any.whl
.
File metadata
- Download URL: queutils-0.8.4-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d40b483408d9c66c1d7bb229043f17fca821c1eca38cac66e029a2c83e271e1a |
|
MD5 | fd871a5379df7f392f04a767533f65c0 |
|
BLAKE2b-256 | 31d5b61bc79ba4095fac8be53371e4f073dab2fd10e1b3e33254ba167fe77599 |