Skip to main content

A concurrent.futures.Executor implementation that runs asynchronous tasks in an asyncio event loop.

Project description

aio-executor

Build Status

A concurrent.futures.Executor implementation that runs asynchronous tasks in an asyncio loop.

Example usage:

from aio_executor import AioExecutor

async def my_async_function(arg):
    # ...

with AioExecutor() as aioexec:
    # single invocation
    f = aioexec.submit(my_async_function, 'foo')
    result = f.result()

    # multiple concurrent invocations using "map"
    results = aioexec.map(my_async_function, ['foo', 'bar', 'baz'])

As a convenience, a run_with_asyncio decorator is also provided. This decorator runs the decorated async function in a AioExecutor instance.

The example below shows how to implement an async view function for the Flask framework using this decorator:

@app.route('/')
@run_with_asyncio
async def index():
    return await get_random_quote()

How to Install

pip install aio-executor

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 aio-executor, version 0.2.0
Filename, size File type Python version Upload date Hashes
Filename, size aio_executor-0.2.0-py2.py3-none-any.whl (3.5 kB) File type Wheel Python version py2.py3 Upload date Hashes View hashes
Filename, size aio-executor-0.2.0.tar.gz (2.6 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page