JavaScript-style async programming for Python.
Project description
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
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 promisio-0.1.1.tar.gz.
File metadata
- Download URL: promisio-0.1.1.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aadc7df7d3b3ab6d9b65050064b098cdd043ffecc65de539eff1dc78f7067c78
|
|
| MD5 |
7eb13f103b8838b97cf94e3a60963903
|
|
| BLAKE2b-256 |
53d7b08bfcb43f9bf8e3e599da494a5f6ed3dabe7ef3e60c24cebcc187233ee6
|
File details
Details for the file promisio-0.1.1-py3-none-any.whl.
File metadata
- Download URL: promisio-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27ebe7c3f3829cc4598cea175931bcd45ed7492a811b3a37d145e074cf04d530
|
|
| MD5 |
c840fdd72e38b3deb5e501fbef49b1ce
|
|
| BLAKE2b-256 |
60b57a47007a1dabaff3cfdee472ae9fd49b49d2b2a9e9b5c7b14581c52af8a8
|