Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Discussion options

You must be logged in to vote

Interesting idea, but I'm afraid I think it will not be implemented.

Here is why:

Details

It's not as simple as it seems to implement this.
Imagine you added bg_tasks: ConcurrentBackgroundTasks as a parameter to one dependency and bg_tasks: BackgroundTasks to another dependency that are both used in the same endpoint. How should FastAPI resolve this? In current implementation both bg_tasks will point to the same instance of BackgroundTasks.

Alternative approach could be to add a parameter like bg_tasks_class to FastAPI() and then use this class to create an instance:

# This doesn't work, it's just to illustrate possible approach

app = FastAPI(bg_tasks_class=ConcurrentBackgroundTasks)

@app.

Replies: 1 comment 3 replies

Comment options

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

@afzalIbnSH-locus
Comment options

@ScrimForever
Comment options

Answer selected by YuriiMotov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question or problem
4 participants