Skip to main content

A coroutine builder

Project description

async-chain

A coroutine builder

What?

Have you ever felt that the await syntax in Python was a bit clunky when chaining multiple methods together?

async def on_message(event):
    message = await event.get_message()
    author = await message.get_author()
    await author.send_message("Hello world!")

Or even worse:

async def on_message(event):
    (await (await (await event.get_message()).get_author()).send_message("Hello world!"))

async-chain is here to solve your problem!

async def on_message(event):
    await event.get_message().get_author().send_message("Hello world!")

How?

First, install async_chain with your favorite package manager:

$ pip install async_chain
$ pipenv install async_chain
$ poetry add async_chain

Then, add the @async_chain.method decorator to any async method you wish to make chainable, and the problem will be magically solved!

import async_chain

class MyEvent:
    @async_chain.method
    async def get_message(self):
        ...

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

async-chain-0.1.2.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

async_chain-0.1.2-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file async-chain-0.1.2.tar.gz.

File metadata

  • Download URL: async-chain-0.1.2.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.9.5 Linux/5.12.9-arch1-1

File hashes

Hashes for async-chain-0.1.2.tar.gz
Algorithm Hash digest
SHA256 c2e3648fb5acfe850c051a38aeee130429fd0a462613553493f112c9535de664
MD5 993063a362190aa62b638c29af0e53f0
BLAKE2b-256 ffe00d2153348973461dad662234567b3fd143ba18bbdb1d6fc3655cf51e3173

See more details on using hashes here.

File details

Details for the file async_chain-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: async_chain-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.9.5 Linux/5.12.9-arch1-1

File hashes

Hashes for async_chain-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 32acf3225391d0c152ab9465e2b9ec3e67e5a45c7afa817953c9b7358a3dbe79
MD5 0deece99dc98adf9a5a62ed4537405e9
BLAKE2b-256 16910d9588e8e3002aea3112007caab82b988eb9e3b6adc74aab900cca306a1f

See more details on using hashes here.

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