Skip to main content

No project description provided

Project description



Aioexec is a simple, intuitive interface around the concurrent.futures package and asyncio's loop.run_in_executor method. Aioexec is leightweight, no dependencies and ~100 LOC.


aioexec requires Python >= 3.6


pip install aioexec


pipenv install aioexec


Without aioexec you usually run an executor something like this:

import aysncio
from concurrent.futures import ProcessPoolExecutor

# ...

loop = asyncio.get_event_loop()

foo = await loop.run_in_executor(
    ProcessPoolExecutor(1), lambda: my_func(foo='baz')

With aioexec you would do the same like this:

from aioexec import Procs

# ...

foo = await Procs(1).call(my_func, foo='baz')

You can call a batch of functions in the same executor like this:

import asyncio
from aioexec import Procs, Call

# ...

my_values = await asyncio.gather(
        Call(my_func, foo='bar'),
        Call(my_func, foo='baz'),
        Call(my_func, foo='qux'),

This plays nicely with comprehensions:

import asyncio
from aioexec import Procs, Call

# ...

my_values = await asyncio.gather(
        Call(my_func, foo=i) for i in range(0, 10)

You can also spawn a pool and make multiple different calls with the same executor:

import asyncio
from aioexec import Procs, Call

# ...

with Procs(10) as pool:

    value_a = await, foo='baz')

    value_b = await aio.gather(
            Call(my_func, foo=i) for i in range(0, 10)

    # etc...

The examples from above work the same for Threads, e.g.:

from aioexec import Threads

# ...

foo = await Threads(1).call(my_func, foo='baz')

If necessary, you can pass an event loop to the executors like this:

foo = await Threads(1, my_loop).call(my_func, foo='baz')
foo = await Procs(1, my_loop).call(my_func, foo='baz')

Development / Testing

Clone the repo and install dev packages:

pipenv install --dev

Run tests:

pipenv run python test

Project details

Download files

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

Files for aioexec, version 0.4.0
Filename, size File type Python version Upload date Hashes
Filename, size aioexec-0.4.0-py3-none-any.whl (7.2 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page