A coroutine builder
Project description
async-chain
A coroutine builder
Links
About
The problem
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!")
The solution
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file async_chain-0.1.3.tar.gz.
File metadata
- Download URL: async_chain-0.1.3.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
299b1800cb37dd5c97e6bcdf7cc97d2111119f72fe50c8a4751e2541cf556d0b
|
|
| MD5 |
4375e4c7d7acc057bd882e88cb1dbd6c
|
|
| BLAKE2b-256 |
549c48cafb3baf7296b1928b14386bd7fb239eae5a349ef7b06961207e8075a9
|
File details
Details for the file async_chain-0.1.3-py3-none-any.whl.
File metadata
- Download URL: async_chain-0.1.3-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34a58d704bdee4b6aa85a9ce8136dc031c643c916339894b6af8c53ac9cf0a6a
|
|
| MD5 |
c52b8715564e9c7e2ce86b53b1e92c08
|
|
| BLAKE2b-256 |
f4ac17a79cc0d89bf547c999f546ac4586f6ed5bdd7367dda3130398db202823
|