GUI-friendly library for scheduling processes using coroutines.
Project description
Async Process Scheduler
Current status: BETA. Improved documentation coming soon.
Introduction
Async Process Scheduler is a small Python library which provides a simple, GUI-friendly way to efficiently run many processes while avoiding the drawbacks of a callback-based data flow.
Async Process Scheduler is compatible with Python 3.6 and higher.
Installation
To install Async Process Scheduler, run pip install AsyncProcessScheduler --user
.
In python, import using import scheduler
.
Usage
After adding processes to a Scheduler
instance, running the processes and getting their results is as simple as await
-ing Scheduler.run()
.
Here is an example which shows the general workflow while simplifying the irrelevant code:
class MyWindow:
### [GUI code removed for simplicity.] ###
def start_scheduler(self):
# Starts the coroutine.
asyncio.ensure_future(self.coro_run())
async def coro_run(self):
self.scheduler = Scheduler()
for i in range(10):
queue = Queue()
process = Process(target=long_calculation, args=(queue,))
self.scheduler.add_task(Task(process, queue))
# Run all processes and get the results without blocking the GUI.
all_results = await self.scheduler.run()
### [Do something with the GUI using the reults.] ###
...
def long_calculation(queue):
### [Do some long calculations, producing x,y,z.] ###
queue.put((
x, y, z # These values will be returned by the scheduler.
))
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.2.0b1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 675b8aeeb0c4c378516d9af8fe037757d0fdde29207baa0bd3990e2fad7b409b |
|
MD5 | 4794d2a428798d5e7c8a0e58b6436f26 |
|
BLAKE2b-256 | 8778c9f70192a37e9b4b39a7433910073f2340f05aa482f0ccc1122decd176e1 |
Hashes for AsyncProcessScheduler-0.2.0b1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd2cd58ee6d77918d9b5ff6d7ae9e7cf7bcdcece3a9956f6e83884811b85c81e |
|
MD5 | 853e1f4b20765ae3808c3ebdec0b94c0 |
|
BLAKE2b-256 | 348c6d6d2179f6b7654e6838e1e4ae47e856c5fd8c4c3f95048f08a8ffa086aa |