GUI-friendly library for scheduling processes using coroutines.
Project description
Async Process Scheduler
Current status: beta.
Introduction
Async Process Scheduler is a small Python library which provides a simple, GUI-friendly way to efficiently run many processes while avoiding a callback-based data flow.
Async Process Scheduler is compatible with multiprocessing
from the standard library, and equivalent implementations such as multiprocess
.
Note: To use Async Process Scheduler in a GUI program, you'll need a library which implements a compatible event loop. For example, asyncqt can be used with PyQt5.
Installation
To install Async Process Scheduler, use pip
:
pip install AsyncProcessScheduler --user
Usage
To use Scheduler
in Python, import from scheduler
:
from scheduler.Scheduler import Scheduler
After adding processes to a Scheduler
instance, running the processes and getting their results is simple:
results: List[Tuple] = await Scheduler.run()
Detailed examples are in the examples folder, including a GUI example using PyQt5. Here is a code snippet which shows the general workflow:
def long_calculation(queue: Queue):
time.sleep(5) # Simulate a long calculation.
queue.put((
"x", "y", "z" # These values will be returned by the scheduler for each process.
))
async def run():
scheduler = Scheduler()
num_processes = 16
for i in range(num_processes):
queue = Queue()
process = Process(target=long_calculation, args=(queue,))
scheduler.add(process, queue)
# Run all processes and get an ordered list containing the results from each.
results: List[Tuple] = await scheduler.run()
# Do something with the results.
print(results)
# Start the coroutine.
asyncio.ensure_future(run())
Design
This diagram demonstrates the implementation of Scheduler
.
Developer notes
Packaging the project
From the documentation:
rm -r dist/
python setup.py sdist
python setup.py bdist_wheel
twine upload dist/*
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
Hashes for AsyncProcessScheduler-0.3.0b1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc44e27cc89c7eec962209dc6f8fd276d1a2e5097d28b6c33c7d8df37eb9b55b |
|
MD5 | a22c4f31c0bc0edb9a95fca8b1c581ad |
|
BLAKE2b-256 | 29f71afd4c145847af72b064ccacbfe8e775ababcec3994c0c96151480b2bbb9 |
Hashes for AsyncProcessScheduler-0.3.0b1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 697056287fd02e401f506c3623552426e4a362fc495e861e39b80aaafb65330d |
|
MD5 | 9cec71ac27743716ac858a509500f718 |
|
BLAKE2b-256 | 686e1e8b1d900905dbab38ea02b220bdca203cae88ca8893f0769c27f743877c |