taskiq-dependencies icon indicating copy to clipboard operation
taskiq-dependencies copied to clipboard

Make arg-reference

Open s3rius opened this issue 2 years ago • 0 comments

This issue comes from the discussion https://github.com/orgs/taskiq-python/discussions/233.

Initial idea is to create a class that can reference arguments of the current function.

async def dependency(sleep_time: float) -> float:
    await asyncio.sleep(sleep_time)
    return sleep_time

async def target(arg: float, sleept: float = TaskiqDepends(dependency, kwargs={"sleep_time": ArgRef("arg")})):
    print(f"short_sleep: {sleept}")

s3rius avatar Oct 24 '23 18:10 s3rius