Replies: 1 comment 2 replies
-
It might be because of different
@broker.task(task_name="add_one")
async def add_one(value: int) -> int:
return value + 1 |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
% pwd
/Users/sector119/PycharmProjects/epsilon_tasks
% ls
Makefile README epsilon_tasks pdm.lock pyproject.toml
Running worker like "taskiq worker epsilon_tasks.test:broker" I get
[2024-02-06 17:32:56,177][taskiq.worker][INFO ][MainProcess] Starting 2 worker processes.
[2024-02-06 17:32:56,182][taskiq.process-manager][INFO ][MainProcess] Started process worker-0 with pid 26371
[2024-02-06 17:32:56,184][taskiq.process-manager][INFO ][MainProcess] Started process worker-1 with pid 26372
task "broker:add_one" is not found. Maybe you forgot to import it?"
What should I change to make taskiq find add_one task?
Thank You
I use example from site
`import asyncio
from taskiq_aio_pika import AioPikaBroker
from taskiq_redis import RedisAsyncResultBackend
broker = AioPikaBroker(
"amqp://guest:guest@localhost:5672",
).with_result_backend(RedisAsyncResultBackend("redis://localhost"))
@broker.task
async def add_one(value: int) -> int:
return value + 1
async def main() -> None:
await broker.startup()
# Send the task to the broker.
task = await add_one.kiq(1)
# Wait for the result.
result = await task.wait_result(timeout=2)
print(f"Task execution took: {result.execution_time} seconds.")
if not result.is_err:
print(f"Returned value: {result.return_value}")
else:
print("Error found while executing task.")
await broker.shutdown()
if name == "main":
asyncio.run(main())
`
Beta Was this translation helpful? Give feedback.
All reactions