asyncrunner
asyncrunner is an asyncio-based asynchronous task runner designed to help you easily implement concurrent task management. It supports task timeout control, concurrency limits, and callback functions after task completion, meeting most asynchronous task scheduling needs.
Installation
You can install the package via pip:
pip install async-task-runner
Or build and install using Poetry:
# Build package (in project root directory)
poetry build
# Install the generated package (assuming the generated file is async-task-runner-1.0.0-py3-none-any.whl)
pip install dist/async-task-runner-1.0.0-py3-none-any.whl
Features
- High-performance Async Scheduling: Implemented based on asyncio, fully utilizing Python's asynchronous features
- Concurrency Control: Uses
asyncio.Semaphoreto control the number of simultaneously running tasks - Task Timeout Control: Uses
asyncio.wait_forto set timeout for each task - Task Callbacks: Supports triggering callback functions after task completion
- Flexible Task Scheduling Interface:
run_tasks: Schedule tasks through a list of task dictionaries, each task dictionary should containtarget(task coroutine function) and other parametersrun_tasks_by_list: Schedule tasks through parameter lists, suitable for cases where parameters are provided in list/tuple or dictionary form
Usage
import asyncio
from asyncrunner import AsyncRunner
async def example_task(x):
await asyncio.sleep(1)
return x * 2
async def main():
# Create runner instance
runner = AsyncRunner(max_workers=3) # Limit concurrent tasks to 3
# Prepare tasks
tasks = [
{"target": example_task, "args": (i,)} for i in range(5)
]
# Run tasks and get results
results = await runner.run_tasks(tasks)
print(results) # [0, 2, 4, 6, 8]
if __name__ == "__main__":
asyncio.run(main())
License
This project is licensed under the MIT License.
Metadata
Release files for async-task-runner 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| async_task_runner-1.0.3.tar.gz | 3.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| async_task_runner-1.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.4 kB
Release files / async_task_runner-1.0.3.tar.gz
| Download URL | async_task_runner-1.0.3.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ab995709daa71da027e2fadd6887aace65448d667bc9debed219461bb61ed889
|
|
BLAKE2b-256 checksum How to use checksums |
464a2473530c62167a12e38c18fc54396d99ddcc7ab47a4d1a3f7ab61833e700
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 4, 2025.
Transparency logRelease files / async_task_runner-1.0.3-py3-none-any.whl
| Download URL | async_task_runner-1.0.3-py3-none-any.whl |
|---|---|
| Size | 4.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
28e37e2c8d835e1e7806171700f09b3f742d4092a84047f2cd2cd8eadbf34e93
|
|
BLAKE2b-256 checksum How to use checksums |
83cb18a13140a3ab1c482128df365a76cecd26b7f2469e0a3d600565a3eac427
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 4, 2025.
Transparency log