Skip to content

Aarq

aioq.Aarq is the central application object. It holds the broker, task registry, and cron list.

Constructor

from aioq import Aarq
from aioq.backends import RedisBroker

app = Aarq(broker=RedisBroker())
Parameter Type Description
broker BaseBroker Broker instance to use for all operations

@app.task(...)

Register an async function as a task.

@app.task(
    queue: str = "default",
    retries: int = 0,
    retry_delay: float = 5.0,
    save_result: bool = False,
    result_ttl: int = 3600,
)
async def my_task(ctx, ...): ...

Returns a TaskDef instance.

@app.cron(...)

Register an async function as a recurring cron task.

@app.cron(
    expression: str,       # Standard cron expression
    queue: str = "default",
    name: str | None = None,
)
async def my_cron(ctx): ...

Requires pip install "aioq[cron]".

app.get_task(name)

Look up a registered task by its dotted name.

task_def = app.get_task("myapp.tasks.send_email")

Returns TaskDef | None.

app.task_names

Property returning a list of all registered task names.

print(app.task_names)
# ['myapp.tasks.send_email', 'myapp.tasks.add']

app.broker

Direct access to the broker instance.

stats = await app.broker.queue_stats()