Skip to main content

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

Project description

AsyncIO Task Runner (Coro Runner)

Test OK! PyPI

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.
  • Worker Queue: Multiple queue can be configued along with their priority.

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

Installation

To install coro-runner, use pip:

pip install coro-runner

Full documentation

Here is the full documentation

Quickstart

  • Define and schedule tasks:

    from coro_runner import CoroRunner
    
    
    runner = CoroRunner(concurrency=10)
    # Add your tasks from anywhere b       
    runner.add_task(your_task, args=[1,2,3], kwargs={"test": "OK!"}) # your_task must be a async function
    

    Declare the runner once and call from everywhere.

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 example:app --reload
    
  2. Trigger tasks using the endpoint:

    GET /fire-task?count=25
    

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.2.4.tar.gz (11.0 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.2.4-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: coro_runner-0.2.4.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.17

File hashes

Hashes for coro_runner-0.2.4.tar.gz
Algorithm Hash digest
SHA256 3d256251d4d549bcd368384245647b7ae0cc493bce73afa7d72f0e9c1e239228
MD5 4123cb296f39cd7dd3272e5b6d37f63a
BLAKE2b-256 0e2e6a5779cbc83ae16d557650231e01c02a6a315f10bebe61379e6e9e9f72a1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for coro_runner-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 b916c0181c5db0fa3ad0cabaead4fa048ee34d02b8edca1a651732cf70a4e134
MD5 7d5511d0d0c1f370ce7a5d022698d2cd
BLAKE2b-256 bfc9af71ae000a3cec3527d6402a31457344d3664148d43242016de11ed235dd

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