[X] I have searched open or closed issues and found nothing related to my idea.
[X] I have read the Documentation and it doesn't mention anything about my idea.
[X] To my best knowledge, my idea wouldn't break something for other users.
Describe your Idea
Currently, Starlette supports on_startup and on_shutdown hooks for running startup and shutdown tasks. However, these hooks have certain limitations and are not as robust as the lifespan approach, which uses async context managers.
Use Cases
The lifespan approach provides a more structured and reliable way to handle startup and shutdown tasks, and it is recommended by the ASGI specification (https://asgi.readthedocs.io/en/latest/specs/lifespan.html). This proposal aligns with the ASGI specification and promotes best practices for handling startup and shutdown tasks in Starlette applications in our APIs such as WebGear and WebGear_RTC which uses it.
Issue guidelines
Issue Checklist
Describe your Idea
Currently, Starlette supports
on_startup
andon_shutdown
hooks for running startup and shutdown tasks. However, these hooks have certain limitations and are not as robust as thelifespan
approach, which uses async context managers.Use Cases
The
lifespan
approach provides a more structured and reliable way to handle startup and shutdown tasks, and it is recommended by the ASGI specification (https://asgi.readthedocs.io/en/latest/specs/lifespan.html). This proposal aligns with the ASGI specification and promotes best practices for handling startup and shutdown tasks in Starlette applications in our APIs such as WebGear and WebGear_RTC which uses it.Any other Relevant Information?
Related Issues: