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
Install by running pip install AsyncProcessScheduler --user
.
Import with 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.1.0b1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c78e4f092907a093ece6abe937ebc1dcb4e7d6a27d7cb67d57353aa90597c98 |
|
MD5 | f334f815875a2f59b02b8ce810059fd2 |
|
BLAKE2b-256 | 5c08bbf230bbdf4db30e79ca25aa6e753c5974f1cddfe46004e4e3d86fd9c040 |
Hashes for AsyncProcessScheduler-0.1.0b1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae1bbf589f9ca79b365a34a8047ac8225ee292e4cd9fc25b8b24eef76e47942e |
|
MD5 | 1a109810a4295e9e86e9f10729c1eabe |
|
BLAKE2b-256 | 51b92da80195f8fe34a1b95bd89526c14b87a87ae12d5ed22288c61f3150b1a1 |