import asyncio
import sys

from streaq import Worker, WrappedContext


async def test_reclaim_idle_task(redis_url: str):
    worker1 = Worker(redis_url=redis_url, queue_name="test")

    @worker1.task(timeout=3)
    async def foo(ctx: WrappedContext[None]) -> None:
        await asyncio.sleep(2)

    await worker1.run_async()


if __name__ == "__main__":
    redis_url = sys.argv[1]
    asyncio.run(test_reclaim_idle_task(redis_url))
