Metadata-Version: 2.4
Name: aion-scheduler
Version: 0.1.0
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
License-File: LICENSE
Summary: Run async functions in Rust
Requires-Python: >=3.12
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM

# aion

**Async job scheduling for Python, powered by Rust’s Tokio runtime.**

`aion` lets you schedule and run asynchronous jobs in Python with **Rust-level performance**.
It bridges Python’s `asyncio` world with Rust’s high-performance **Tokio** runtime — giving you
a faster, safer way to execute async tasks, periodic jobs, and cron-like schedules.

## ✨ Features

- 🚀 **Powered by Rust Tokio** — concurrency with minimal overhead
- 🧩 **Python async compatible** — runs within existing `asyncio` loops
- ⏰ **Job scheduling** — supports delayed, periodic, and cron-style scheduling
- 🔄 **Thread-safe** — Rust-backed atomic control and synchronization
- 🧠 **Lightweight** — no background daemon or external broker required

## 📦 Installation

Install directly from PyPI (once published):

```bash
pip install aion-scheduler
```

```

## 🧠 Quick Start

Here’s a simple example showing how to schedule async jobs using aion.

```python
import asyncio
from datetime import timedelta
from aion import Scheduler, Trigger

async def hello():
    print("Hello from Aion!")

async def main():
    scheduler = Scheduler()

    # Run every 1 second
    await scheduler.schedule(handler=hello, trigger=Trigger.Interval(timedelta(seconds=1)))

    # Run immediately
    await hello()

    # Keep the scheduler running
    await scheduler.start()

asyncio.run(main())
```

### Cron expressions

You can also schedule jobs using cron-like syntax:

```python
import asyncio
from aion import Scheduler, Trigger

async def report():
    print("Generating report...")

async def main():
    scheduler = Scheduler()
    await scheduler.schedule(handler=report, trigger=Trigger.Cron("0 * * * *"))  # Run every hour
    await scheduler.start()

asyncio.run(main())
```

## ⚙️ API Overview

| Function / Class   | Description |
|--------------------|-------------|
| Scheduler          | Core job scheduler managing async task lifetimes.          |
| Scheduler.schedule | Puts an async function onto the scheduler.                 |
| Scheduler.start    | Starts the scheduler, this will block forever.             |
| Scheduler.pause    | Pause a scheduled job, can be resumed.                     |
| Scheduler.resume   | Resumes a paused job, no effect if job is not paused.      |
| Scheduler.shutdown | Shutdown the scheduler, all scheduled jobs will also exit. |
| Trigger            | Represents a method of invoking a job.                     |


## 🧪 Testing

`aion` uses `pytest` and `pytest-asyncio`.

Run all tests:

```bash
uv run pytest -v
```

## 🛠️ Developer Guide

To rebuild the Python extension:

```bash
uv sync --reinstall # rebuild the rust lib and loads it into venv
```

To check the Rust code:

```bash
cargo check
cargo test
```

To format code:

```bash
cargo fmt
ruff check . --fix
```

### Directory structure

```bash
aion/
├── src/              # Rust sources
├── aion/             # Python module
├── examples/         # Usage examples
├── tests/            # Python tests
├── Cargo.toml        # Rust dependencies
└── pyproject.toml    # Python packaging
```

## 📄 License

Copyright © 2025 Balaena Quant

All rights reserved. This is a proprietary and confidential work.
Unauthorized use, duplication, or distribution is prohibited.

## 🌌 Why “Aion”?

In ancient Greek, Aion represents eternal time — the endless flow that powers all things.
This library brings that concept to async programming: efficient, perpetual scheduling powered by Rust.

