on_event() — fastapi Function Reference
Architecture documentation for the on_event() function in applications.py from the fastapi codebase.
Entity Profile
Dependency Diagram
graph TD dac05d36_d298_20ac_8313_653329a27887["on_event()"] 587454b3_6db6_011f_9fa4_3e4e2e09b72d["FastAPI"] dac05d36_d298_20ac_8313_653329a27887 -->|defined in| 587454b3_6db6_011f_9fa4_3e4e2e09b72d a27c576c_fb92_8398_f37e_212c576404a2["on_event()"] dac05d36_d298_20ac_8313_653329a27887 -->|calls| a27c576c_fb92_8398_f37e_212c576404a2 style dac05d36_d298_20ac_8313_653329a27887 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
fastapi/applications.py lines 4560–4579
def on_event(
self,
event_type: Annotated[
str,
Doc(
"""
The type of event. `startup` or `shutdown`.
"""
),
],
) -> Callable[[DecoratedCallable], DecoratedCallable]:
"""
Add an event handler for the application.
`on_event` is deprecated, use `lifespan` event handlers instead.
Read more about it in the
[FastAPI docs for Lifespan Events](https://fastapi.tiangolo.com/advanced/events/#alternative-events-deprecated).
"""
return self.router.on_event(event_type)
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does on_event() do?
on_event() is a function in the fastapi codebase, defined in fastapi/applications.py.
Where is on_event() defined?
on_event() is defined in fastapi/applications.py at line 4560.
What does on_event() call?
on_event() calls 1 function(s): on_event.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free