Skip to content

TypeError: BrokerWrapper.task.<locals>.<lambda>__taskiq_original() takes 0 positional arguments but 1 was given #78

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
glambary opened this issue Apr 16, 2025 · 1 comment

Comments

@glambary
Copy link

glambary commented Apr 16, 2025

kafka_router = KafkaRouter(
    settings.kafka.KAFKA_BROKER,
    include_in_schema=True,
)

taskiq_broker = BrokerWrapper(kafka_router.broker)

taskiq_scheduler = TaskiqScheduler(
    broker=taskiq_broker,
    sources=[LabelScheduleSource(taskiq_broker)],
)

@taskiq_broker.task
async def sync_last_bets() -> None:
    td = timedelta(minutes=10, seconds=30)
    await sync_service.sync_bets(batch_size=100, time_delta=td)

I need to run the task once.

if i set @taskiq_broker.task exc that schedule parameter is required.
if I set it this way (@taskiq_broker.task(schedule=[{"cron": "0 0 31 2 *"}])) and try to run it manually in lifespan fastapi
bootstrap.py:

from broker.tasks import sync_bets_once
await sync_bets_once.kiq()

Exc:
File "/home/shakdevich/Dropbox/python/Funtech/scannerservice/project/core/bootstrap.py", line 34, in lifespan
await run_tasks()
File "/home/shakdevich/Dropbox/python/Funtech/scannerservice/project/core/bootstrap.py", line 75, in run_tasks
from broker.tasks import sync_init_bets
File "/home/shakdevich/Dropbox/python/Funtech/scannerservice/project/broker/tasks.py", line 24, in
@taskiq_broker.task(schedule=[{"0 0 31 2 *"}}])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/shakdevich/.cache/pypoetry/virtualenvs/scannerservice-Wg8Y1DKw-py3.12/lib/python3.12/site-packages/taskiq/decor.py", line 98, in call
return self.original_func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: BrokerWrapper.task..__taskiq_original() takes 0 positional arguments but 1 was given

@Lancetnik
Copy link
Collaborator

@s3rius can you help me here, please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants