promisio
JavaScript-style async programming for Python.
Examples
Create a promise-based async function using the promisify decorator. It works
on both sync and async functions!
from promisio import promisify
@promisify
async def f():
await asyncio.sleep(1)
return 42
@promisify
def g(x):
return x * 2
async def main():
print(await f()) # prints 42
print(await g(42)) # prints 84
promise = f() # runs function in the background without waiting
# ... do other stuff here in parallel with f running
await promise # finally wait for f to complete
The return value of the decorated function is a JavaScript-style promise object
that can be awaited. The then(), catch() and finally_() methods to chain
promises work as in JavaScript. The Promise.all(), Promise.all_settled(),
Promise.any(), Promise.race(), Promise.resolve() and Promise.reject()
are also available. Promises in this package are extended to also support
cancellation via the cancel() and cancelled() methods.
Resources
Metadata
Release files for promisio 0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| promisio-0.2.tar.gz | 11.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| promisio-0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.3 kB
Release files / promisio-0.2.tar.gz
| Download URL | promisio-0.2.tar.gz |
|---|---|
| Size | 11.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
80fdb440254c8b4ac390c9bd3aadc784d3a0684163add243c095abbaa98ea098
|
|
BLAKE2b-256 checksum How to use checksums |
b261caeb325f5a5b4cfa0f0538e1cef5de8acae42d099046564729cee8ed5d00
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Release files / promisio-0.2-py3-none-any.whl
| Download URL | promisio-0.2-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
804d9a35ced1aac079a06319bc31a98ef218b5bb65a18e1cf280335bf78c4f9e
|
|
BLAKE2b-256 checksum How to use checksums |
9d27cdff9e9582bf76399585e864f30d6c0594a303f9b7dc32cbd487c4e84cef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|