aqueue 0.9.2

Last updated:

0 purchases

aqueue 0.9.2 Image
aqueue 0.9.2 Images
Add to Cart

Description:

aqueue 0.9.2

aqueue is an async task queue with live progress display.
You put items (tasks) in, and they get processed, possibly creating more items which
get processed, and so on, until all items are completed. A typical use case would be to scrape a
website.
Meanwhile, a nice visualization of the queue’s goings-on is displayed in the terminal.


Note
aqueue, or any asynchronous framework, is only going to be helpful if you’re performing
I/O-bound work.


Installation
aqueue is a Python package hosted on PyPI. The recommended
installation method is pip-installing into a virtual
environment:
pip install aqueue


Getting Started
There’s two things you need to do to use aqueue:

Implement your Item subclasses.
Start your queue with one of those
items.



Example
If you had a hierarchy of items like this…

Then, you might process it with aqueue like this…
import aqueue


class RootItem(aqueue.Item):
async def process(self) -> aqueue.ProcessRetVal:
# display what we're doing in the worker status panel
self.set_worker_desc("Processing RootItem")

# make an HTTP request, parse it, etc
...

# when you discover more items you want to process, enqueue them by yield-ing
# them:
for _ in range(3):
yield ChildItem()

async def after_children_processed(self) -> None:
# run this method when this Item and all other Items it enqueued are done
print("All done!")


class ChildItem(aqueue.Item):

# track the enqueueing and completion of these items in the overall panel
track_overall: bool = True

async def process(self) -> aqueue.ProcessRetVal:
self.set_worker_desc("Processing ChildItem")
# this child item has no further children to enqueue, so it doesn't yield
# anything


if __name__ == "__main__":
aqueue.run_queue(
initial_items=[RootItem()],
num_workers=2,
)


Project Information

License: MIT
PyPI: https://pypi.org/project/aqueue/
Source Code: https://github.com/t-mart/aqueue
Documentation: https://t-mart.github.io/aqueue/
Supported Python Versions: 3.10 and later

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.