Tools to bridge coroutines and non-coroutine awaitables in Python
Project description
Awaitable Tools
This package provides utilities for working with awaitable objects in Python.
Coroutines vs Awaitables
Coroutines
Objects returned from the function declared with the async def syntax.
It is the standard way to create asynchronous programs.
async def coroutine():
pass
Awaitable
Any object that implements __await__() for use in an await expression.
class Awaitable:
def __await__(self):
yield
Installation
pip install awaitable-tools
While most users work with coroutines, some advanced scenarios (like protocol implementations or framework development) require working directly with awaitables. This package fills that gap.
Technical Background
The Awaitable Protocol
An object is awaitable if its __await__() method returns an generator that:
- Only yields
None(any other value raisesRuntimeError) - Final value uses
return(notyield) - May use
yield fromwith other compliant generators
class ValidAwaitable:
def __await__(self):
yield None # Valid suspension
# coroutine also implements __await__()
yield from asyncio.sleep(1).__await__()
return True
class InvalidAwaitable:
def __await__(self):
# Only valid if marked as @types.coroutine
yield from asyncio.sleep(1) # TypeError!
yield "foo" # RuntimeError!
About async/await
Project details
Release history Release notifications | RSS feed
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 awaitable_tools-0.0.1.tar.gz.
File metadata
- Download URL: awaitable_tools-0.0.1.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a2f5d4031b11741bd9acaba8f6bdc2b4b420abe70ecab6c22901faa70d19c44
|
|
| MD5 |
7afa9c76a12f51bc5c515be65ef7e197
|
|
| BLAKE2b-256 |
337e7f72f4498636ff672022850d4ae9ef9b3ecf319c96f174e7c7751a76ea2a
|
Provenance
The following attestation bundles were made for awaitable_tools-0.0.1.tar.gz:
Publisher:
python-publish.yml on AlanBogarin/awaitable-tools
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
awaitable_tools-0.0.1.tar.gz -
Subject digest:
8a2f5d4031b11741bd9acaba8f6bdc2b4b420abe70ecab6c22901faa70d19c44 - Sigstore transparency entry: 780050289
- Sigstore integration time:
-
Permalink:
AlanBogarin/awaitable-tools@76685e4bb20388eea4d2613bf100b122de114fc6 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/AlanBogarin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@76685e4bb20388eea4d2613bf100b122de114fc6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file awaitable_tools-0.0.1-py3-none-any.whl.
File metadata
- Download URL: awaitable_tools-0.0.1-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9382020fdbc680b74cde8aafb1edfc2b172b46c874d9dd7afc1450582028802c
|
|
| MD5 |
84fdf9b67c370e25ef2d963711128184
|
|
| BLAKE2b-256 |
5e441922ba8045a17ab05a9bde4e02d78c4e8ea8eb09be28cceef05b6a091b21
|
Provenance
The following attestation bundles were made for awaitable_tools-0.0.1-py3-none-any.whl:
Publisher:
python-publish.yml on AlanBogarin/awaitable-tools
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
awaitable_tools-0.0.1-py3-none-any.whl -
Subject digest:
9382020fdbc680b74cde8aafb1edfc2b172b46c874d9dd7afc1450582028802c - Sigstore transparency entry: 780050290
- Sigstore integration time:
-
Permalink:
AlanBogarin/awaitable-tools@76685e4bb20388eea4d2613bf100b122de114fc6 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/AlanBogarin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@76685e4bb20388eea4d2613bf100b122de114fc6 -
Trigger Event:
release
-
Statement type: