Skip to content

How to use fastapi dependencies in taskiq tasks (or what I am missing) #188

Answered by s3rius
devraj asked this question in Q&A
Discussion options

You must be logged in to vote

I guess, that problem is because now tasks resolved after startup.
Before the release https://github.com/taskiq-python/taskiq-fastapi/releases/tag/0.3.0 taskiq-fastapi was resolving all tasks, used by an application before startup. Now it does it during the startup. Because this behavior was causing bugs, when application uses multiple brokers.

Since taskiq calculates all dependency graphs on startup, we need to know about all tasks before the startup event. To solve your problem, you can either use --fs-discover parameter, or add modules with your tasks directly to worker command.

taskiq worker app.tkq:broker app.tasks

Or

taskiq worker app.tkq:broker --fs-discover

All tasks imported like…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@s3rius
Comment options

@s3rius
Comment options

@devraj
Comment options

Answer selected by devraj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants