Define a task
Submit a task
Add task options
retries: retry transient failurestimeout: stop runaway worklock: prevent duplicate work for the same keyprocess=True: run in a separate process for isolation
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Run async work and recurring jobs without a separate worker stack.
@app.task(retries=2, timeout=300)
async def sync_threads(owner_id: str):
return {"synced": 25, "owner_id": owner_id}
@app.message()
async def handle(session: cpsl.Session, msg: cpsl.Message):
handle = await sync_threads.submit(owner_id=session.user.owner_id)
await session.show_task(handle, message="Sync started")
@app.task(
retries=3,
timeout=600,
lock="owner:{owner_id}",
process=True,
)
async def rebuild_index(owner_id: str):
...
retries: retry transient failurestimeout: stop runaway worklock: prevent duplicate work for the same keyprocess=True: run in a separate process for isolation@app.schedule("0 * * * *")
async def hourly_sync():
await sync_threads.submit(owner_id="system")
@app.page("Tasks", icon="list-check")
def tasks_page():
return cpsl.ui.Page([cpsl.ui.TaskBoard(title="Tasks")])