Skip to main content

It's a python based asyncio task schedular/queue mechanism

Project description

AsyncIO Task Runner (Coro Runner)

The AsyncIO Task Runner (Coro Runner) is a Python utility designed for managing concurrent asynchronous tasks using the built-in asyncio module. It provides an efficient way to execute multiple tasks in a single-threaded environment with customizable concurrency limits.

This project leverages asyncio (introduced in Python 3.4) to simplify handling of asynchronous workloads, making it ideal for lightweight, scalable applications.

Features

  • Configurable Concurrency: Define the number of concurrent tasks when initializing the runner.
  • Efficient Task Management: Run multiple tasks concurrently with streamlined execution control.

Planned Enhancements

  • Monitoring Tool Integration: Support for real-time task monitoring and analytics.
  • Low-Level API: Features such as callbacks, acknowledgments, and error handling for advanced use cases.
  • Robust Logging: Detailed logging to track task execution and debug issues.

Getting Started

Prerequisites

  • Python 3.12 or later
  • Poetry for dependency management

Installation and Setup

  1. Clone the repository:

    git clone https://github.com/iashraful/async-coro-runner.git
    cd async-coro-runner
    
  2. Activate the virtual environment:

    poetry shell
    
  3. Install dependencies:

    poetry install
    

Running Tests

Run the test suite to verify the setup:

pytest -s

Sample Output:

Task started:  Task-1
Task ended:    Task-1
...

Example Usage

The project includes an example API implemented with FastAPI. It demonstrates how to use the task runner to manage asynchronous tasks.

Starting the API

  1. Run the API server:

    uvicorn main:app --reload
    
  2. Trigger tasks using the endpoint:

    GET /fire-task?count=25
    

Code Highlights

  • Define and schedule tasks:
    runner = CoroRunner(concurrency=25)
    runner.add_task(rand_delay())
    
  • Task lifecycle management:
    async def startup():
        await runner.run_until_exit()
    
    async def shutdown():
        await runner.cleanup()
    

How to Contribute

Contributions are welcome! Follow these steps to get started:

  1. Fork the repository and create a new branch for your feature or bug fix.
  2. Write tests for your changes.
  3. Open a pull request with a clear description of your contribution.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

coro_runner-0.0.2.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

coro_runner-0.0.2-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file coro_runner-0.0.2.tar.gz.

File metadata

  • Download URL: coro_runner-0.0.2.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.13.0 Darwin/24.1.0

File hashes

Hashes for coro_runner-0.0.2.tar.gz
Algorithm Hash digest
SHA256 67127c99969d21aeff7ab764a6d36a24bebec22d889e53a838d2707dfb4207be
MD5 6cb7fb562a8ad041068d4c61bc2b562a
BLAKE2b-256 0f9d76b2d2138bd7dc2b770fb913a9fd6959edcd00eaa85a9f31514c0cb4a48a

See more details on using hashes here.

File details

Details for the file coro_runner-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: coro_runner-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.13.0 Darwin/24.1.0

File hashes

Hashes for coro_runner-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1298a8f6e9e2ccc600072e7f31e27f6c28fb3c8b2b1529154a3d78b8b0b784f1
MD5 824e4f20fd72f89c4ee60c81d2b8e64f
BLAKE2b-256 d4110a967c8760567d48123426f395755a3ea7aa68fcdb6c40003a0fc3dabf0a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page