ManiMozaffar / aioclock

A modern python scheduling framework with dependency injection and modular integration support. Alternative for Rocketry or apscheduler
https://manimozaffar.github.io/aioclock/
MIT License
160 stars 5 forks source link

Bring timeout support for scheduled tasks in aioclock #26

Closed mahdihaghverdi closed 2 months ago

mahdihaghverdi commented 2 months ago

What's new

Groups

Set a timeout for a group of tasks.

group = Group(timeout=4)

@group.task(trigger=Every(...))
async def _(...):   # this task will fail every time it runs
    await asyncio.sleep(6)  

set a timeout for each task

group = Group(timeout=4)

@group.task(trigger=Every(...))  # this task has the group's timeout
async def _(...): ...

@group.task(trigger=Every(...), timeout=3)  # this task has its specific timeout
async def _(...): ...

App

set a timeout for each task

app = AioClock()

@app.task(trigger=Every(...))  # this task does not have a timeout
async def _(...): ...

@app.task(trigger=Every(...), timeout=3)  # this task has its specific timeout
async def _(...): ...

PS

I didn't know how to write tests for this feature, however all old tests are passed.