Skip to content

Bug: incorrect task names with "__main__" #507

@raidzin

Description

@raidzin

Description

Taskiq generates wrong task names when ivoked with relative paths on windows

MCVE

import asyncio
from taskiq import ZeroMQBroker

broker = ZeroMQBroker()


@broker.task()
async def spam() -> None:
    await asyncio.sleep(0)
    print("eggs")


async def main() -> None:
    await broker.startup()
    await asyncio.sleep(1)
    await spam.kiq()
    await broker.shutdown()


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

Start broker

uv run taskiq worker demo:broker -w 1

And if lounch code with uv run demo.py everything good. But if i use current directory . it does't work


uv run ./demo.py
[taskiq.receiver.receiver][WARNING][worker-0] task "./demo:spam" is not found. Maybe you forgot to import it?

uv run .\demo.py
[taskiq.receiver.receiver][WARNING][worker-0] task "..demo:spam" is not found. Maybe you forgot to import it?

Also it does'n work if i use normal slashes on windows for module/demo.py name will be module/demo it should be module.demo

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions