Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.7k
🐛 Ensure thatapp.include_router merges nested lifespans#9630
🐛 Ensure thatapp.include_router merges nested lifespans#9630tiangolo merged 20 commits intofastapi:masterfrom
app.include_router merges nested lifespans#9630Conversation
📝 Docs preview for commit860c851 at:https://647f7cdb633e285f9b5dace9--fastapi.netlify.app |
app.include_router doesn't nest lifespansapp.include_router doesn't merge nested lifespans📝 Docs preview for commit984e59f at:https://647f7f0b29b2f764bcaa3dd9--fastapi.netlify.app |
tiangolo commentedJun 10, 2023
📝 Docs preview for commit8f26ed5 at:https://6484cca7bf187a105b276a5e--fastapi.netlify.app |
Lancetnik commentedJun 16, 2023
@tiangolo can you take a look here, please? It's a minor bugfix, but it's important for my project. |
app.include_router doesn't merge nested lifespansapp.include_router doesn't merge nested lifespanstiangolo commentedJun 16, 2023
📝 Docs preview for commitf322c99 at:https://648c2ec07c8ac9541405829c--fastapi.netlify.app |
tiangolo commentedJun 17, 2023
📝 Docs preview for commit3e2fd98 at:https://648e16b538df29410a152328--fastapi.netlify.app |
Kludex commentedJun 17, 2023
This is not minor, and ideally we'd like this to live in Starlette. |
Lancetnik commentedJun 18, 2023
@Kludex maybe, but how we can move it to Starlette if |
Lancetnik commentedJun 18, 2023
This will require a lot of work in bothFastAPI andStarlette, since none of theFastAPI methods uses |
Lancetnik commentedJun 18, 2023
Lancetnik commentedJun 23, 2023
@Kludex this bug doesn't onStarlette side and not connected with thisIssue or thisStarlettePR orIssue. It should be fixed inFastAPI cuz we have noStarlette calls inside So can you review and approve this PR? |
Kludex commentedJun 23, 2023
Starlette should support running the lifespan of other routers... It shouldn't be here. |
Lancetnik commentedJun 23, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
But there noother routers. We have the original @Kludex just take a look atFastAPI original codehere AFastAPI application works with an only one original router (if we didn't use |
ovflw commentedJul 12, 2024
+1 |
1 similar comment
Flosckow commentedJul 12, 2024
+1 |
FraterCRC commentedJul 19, 2024
+1) |
ApostolFet commentedJul 19, 2024
+1 |
iNerV commentedJul 19, 2024
Wait for fix |
bomzheg commentedJul 20, 2024
+1 |
1 similar comment
jekel commentedJul 22, 2024
+1 |
Tishka17 commentedJul 30, 2024
@tiangolo can we have a minute of your time here? |
Tishka17 commentedAug 6, 2024
I am sorry to annoy you, but it is 14 months since PR is opened. Can we, as a community, have a decision or plan? |
Lancetnik commentedAug 7, 2024
@svlandeg@estebanx64@alejsdev Hello, team! Sorry for such annoyiment, but we are still waiting for any decision about this PR. FastAPI now has an obvious bug / weaknesses. And we have the PR fixing it. I know, that this thing should be fixed in the future according to Roadmap, but we are waiting year already for it. Have we any reason to not merge 10 lines of code if they fixing the problem already and we can remove them in the future as a part of Roamap feature scope? |
chessenjoyer17 commentedAug 7, 2024
+1 |
3 similar comments
Alkalit commentedAug 7, 2024
+1 |
Cub11k commentedAug 7, 2024
+1 |
chirizxc commentedAug 7, 2024
+1 |
prostomarkeloff commentedAug 7, 2024
dmitryleafall commentedAug 7, 2024
+1 |
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
app.include_router doesn't merge nested lifespansapp.include_router merges nested lifespanstiangolo commentedAug 24, 2024
Thank you for your contribution@Lancetnik! 🍰 Thanks everyone for the input. ☕ Thanks a lot for the help, as always,@Kludex 🙏 🙇 This will be available in FastAPI version Thanks everyone for the patience. As this involved some internal changes, that means there's a bit of a higher chance it could break something else elsewhere (something we didn't expect and didn't account for), so I wanted to handle some other lower-impact issues and releases first. Now I was finally able to sit a few hours dedicated just to this, read several parts of the ASGI spec again, ensure this would be the right way to handle things (e.g. what nested lifespan states should override which), etc. Now, time to enjoy your new nested lifespans. 😎 ☕ |
Uh oh!
There was an error while loading.Please reload this page.
I am working on my ownPropan library and as a part of it I implemented a customFastAPI router with the following behavior.
To connect RabbitMQ atFastAPI startup I used
router.on_startupevents and all worked fine, but now it is deprecated. So I migrate tolifespanand nowFastAPI doesn't run router lifespan at the code above.I suppose it was missed cuz the original
include_routermethod includes all nestedon_startupandon_shutdowndeprecated eventshere, but doesn't includes a router lifespan.So, the following code doesn't work
The current PR fixes the original framework miss.
All original test and lint.sh checks works fine.