async-executor
Async execution pool
Examples
Limit the number of concurrently running awaitables
import asyncio
import time
import async_executor
async def sleep_and_print(i):
print(f'{i} {int(time.time())} - before sleep')
await asyncio.sleep(1)
print(f'{i} {int(time.time())} - after sleep')
async def main():
# limit to a maximum of two concurrent executions
executor = async_executor.AsyncExecutor(max_concurrent=2)
# awaitables are only queued here - nothing is run
for i in range(5):
executor.submit(sleep_and_print, i)
# awaitables begin executing
async for task in executor:
task.result()
asyncio.run(main())
This shows that only a maximum of two executions are allowed to run concurrently.
$ python examples/example_1.py
0 1670613515 - before sleep
1 1670613515 - before sleep
0 1670613516 - after sleep
1 1670613516 - after sleep
2 1670613516 - before sleep
3 1670613516 - before sleep
2 1670613517 - after sleep
3 1670613517 - after sleep
4 1670613517 - before sleep
4 1670613518 - after sleep
Installation
pip install async-executor
License
async-executor is distributed under the terms of the MIT license.
Metadata
Release files for async-executor 0.1.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 | Provenance | Actions |
|---|---|---|---|---|
| async_executor-0.1.2.tar.gz | 2.8 kB | Without provenance | Details for async_executor-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| async_executor-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for async_executor-0.1.2-py3-none-any.whl |
Total release size: 6.0 kB
Release files / async_executor-0.1.2.tar.gz
| Download URL | async_executor-0.1.2.tar.gz |
|---|---|
| Size | 2.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
910e74dd7aaaa2a39f3e3fc91e3f87a01d23bea650fbf431746d2961f928d482
|
|
BLAKE2b-256 checksum How to use checksums |
59bc6bd2b0133f30854235748c7175c598c38e6b18aa3fb70d683dcbea09eda0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.1.dev0+g94f810c.d20240510 CPython/3.12.4
|
Release files / async_executor-0.1.2-py3-none-any.whl
| Download URL | async_executor-0.1.2-py3-none-any.whl |
|---|---|
| Size | 3.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
44596587fae296ce12cfd25127ae91dadeb2f10e81769a7326ac7201b2d24e20
|
|
BLAKE2b-256 checksum How to use checksums |
98c478e168f6847d46e4f86a109ec88ba765fcb9d793c5c1968a44e7b71fc239
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.1.dev0+g94f810c.d20240510 CPython/3.12.4
|
Security for async-executor 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.