Skip to main content

Making asyncio coroutines chainable

Project description

asyncio-chainable

Making asyncio coroutines chainable

Built on: Python3 and Docker (alpine) and Poetry (Package Manager)
Maintained by: Chris Lee [sihrc.c.lee@gmail.com]

Installation

pip3 install asyncio_chainable

Example Usage

import pytest

from asyncio_chainable import async_chainable, async_chainable_class


@pytest.mark.asyncio
async def test_simple_chain():
    class Number:
        def __init__(self, num: int = 0):
            self.num = num

        @async_chainable
        async def add(self, num: int):
            self.num += num
            return self

        @async_chainable
        async def subtract(self, num: int):
            self.num -= num
            return self

    assert (await Number().add(5).subtract(2)).num == 3


@pytest.mark.asyncio
async def test_class_chain():
    @async_chainable_class
    class Number:
        def __init__(self, num: int = 0):
            self.num = num

        async def add(self, num: int):
            self.num += num
            return self

        async def subtract(self, num: int):
            self.num -= num
            return self

    assert (await Number().add(5).subtract(2)).num == 3

Contributing: Getting Started

Docker

  • Additional Python3 dependencies can be added to requirements.txt
  • Tests are located in ./tests
  • To run the docker container with the basic requirements, dependencies, and the package installed:
    $ touch .env
    $ docker-compose up
    

Poetry

$ poetry install

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

asyncio-chainable-0.1.3.tar.gz (3.1 kB view hashes)

Uploaded Source

Built Distribution

asyncio_chainable-0.1.3-py3-none-any.whl (4.1 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