Skip to content

Using lifespan event on APIRoute() instead in FastAPI() #9664

Answered by Kludex
Ammar-Azman asked this question in Questions
Discussion options

You must be logged in to vote

I have asked Mr @tiangolo on Twitter this question and he suggested me to ask in Github so it can benefit others and I am agree with him.

He probably meant to create a discussion, not an issue.

I found that APIRoute() class has lifespan parameter too (same as FastAPI()), but might be require certain or additional configuration to make it happened. Any way that we can apply the lifespan on route?

The APIRouter is the one that accepts lifespan, not APIRoute.

Any way that we can apply the lifespan on route?

For the moment, is not possible.

Replies: 2 comments 8 replies

Comment options

Kludex
Jun 12, 2023
Collaborator Sponsor

You must be logged in to vote
2 replies
@Ammar-Azman
Comment options

@stur86
Comment options

Answer selected by Kludex
Comment options

You must be logged in to vote
6 replies
@naimetti
Comment options

@joshwilson-dbx
Comment options

@noirbizarre
Comment options

@nicocti
Comment options

@kamalkraj
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
9 participants
Converted from issue

This discussion was converted from issue #9663 on June 12, 2023 08:58.