Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

AsyncProcessScheduler-0.1.0b1.tar.gz (5.7 kB view hashes)

Uploaded Source

Built Distribution

AsyncProcessScheduler-0.1.0b1-py3-none-any.whl (9.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page