Skip to main content

A simple asynchronous task queue

Project description

aiotask

A simple asynchronous task queue

Motivation

Existing famously used asynchronous worker library (Celery) doesn't support asyncio and is hard to use. This library aims to help users compose tasks in a very native async-await manner. It is also full-typed for better productivity and correctness.

Simple Usage

import asyncio

import aiotaskq


@aiotaskq.register_task
def some_task(b: int) -> int:
    # Some task with high cpu usage
    def _naive_fib(n: int) -> int:
        if n <= 1:
            return 1
        elif n <= 2:
            return 2
        return _naive_fib(n - 1) + _naive_fib(n - 2)
    return _naove_fib(b)


async def main():
    async_result = await some_task.apply_async(42)
    sync_result = some_task(42)
    assert async_result == sync_result

if __name__ == "__main__":
    asyncio.run_until_complete(main())

Advance usage

# TODO: Example of composing chain of tasks (chord + chain in Celery terms)

Install

pip install aiotaskq

Links

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

aiotaskq-0.0.3.tar.gz (3.7 kB view hashes)

Uploaded Source

Built Distribution

aiotaskq-0.0.3-py3-none-any.whl (4.7 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