"""Run bounded concurrent async work with TaskRuntime."""

from __future__ import annotations

import asyncio

from infra_core import RuntimeConfig, TaskRuntime


async def process_item(item_id: int) -> None:
    await asyncio.sleep(0.2)
    print(f"processed {item_id}")


async def main() -> None:
    runtime = TaskRuntime(config=RuntimeConfig(concurrency=3, task_timeout=5.0))
    jobs = [(f"item-{item_id}", lambda item_id=item_id: process_item(item_id)) for item_id in range(6)]
    await runtime.run(jobs)


if __name__ == "__main__":
    asyncio.run(main())
