Skip to main content
The background command manages background task execution.

Quick Start

# List running background tasks
praisonai background list

Usage

List Tasks

praisonai background list
Expected Output:
╭─ Background Tasks ──────────────────────────────────────────────────────────╮
│  🔄 [abc12345] research_task - running (45s)                                │
│  ✅ [def67890] analysis_task - completed                                    │
│  ❌ [ghi11111] failed_task - failed                                         │
╰──────────────────────────────────────────────────────────────────────────────╯

Check Task Status

praisonai background status <task_id>

Cancel Task

praisonai background cancel <task_id>

Clear Completed

praisonai background clear

Python API

import asyncio
from praisonaiagents.background import BackgroundRunner, BackgroundConfig

async def main():
    config = BackgroundConfig(max_concurrent_tasks=3)
    runner = BackgroundRunner(config=config)
    
    async def my_task(name: str) -> str:
        await asyncio.sleep(2)
        return f"Task {name} done"
    
    task = await runner.submit(my_task, args=("example",))
    await task.wait(timeout=10.0)
    print(task.result)

asyncio.run(main())

See Also