MCPcopy
hub / github.com/fastapi/fastapi / app

Function app

fastapi/routing.py:126–150  ·  view source on GitHub ↗
(scope: Scope, receive: Receive, send: Send)

Source from the content-addressed store, hash-verified

124 ) # ty: ignore[invalid-assignment]
125
126 async def app(scope: Scope, receive: Receive, send: Send) -> None:
127 request = Request(scope, receive, send)
128
129 async def app(scope: Scope, receive: Receive, send: Send) -> None:
130 # Starts customization
131 response_awaited = False
132 async with AsyncExitStack() as request_stack:
133 scope["fastapi_inner_astack"] = request_stack
134 async with AsyncExitStack() as function_stack:
135 scope["fastapi_function_astack"] = function_stack
136 response = await f(request)
137 await response(scope, receive, send)
138 # Continues customization
139 response_awaited = True
140 if not response_awaited:
141 raise FastAPIError(
142 "Response not awaited. There's a high chance that the "
143 "application code is raising an exception and a dependency with yield "
144 "has a block with a bare except, or a block with except Exception, "
145 "and is not raising the exception again. Read more about it in the "
146 "docs: https://fastapi.tiangolo.com/tutorial/dependencies/dependencies-with-yield/#dependencies-with-yield-and-except"
147 )
148
149 # Same as in Starlette
150 await wrap_app_handling_exceptions(app, request)(scope, receive, send)
151
152 return app
153

Callers 7

handleMethod · 0.85
translate.pyFile · 0.85
docs.pyFile · 0.85
prepare_release.pyFile · 0.85
wrapped_appFunction · 0.85
call_nextFunction · 0.85
_run_asgi_and_cancelFunction · 0.85

Calls 15

FastAPIErrorClass · 0.90
EndpointContextClass · 0.90
HTTPExceptionClass · 0.90
solve_dependenciesFunction · 0.90
fFunction · 0.85
_sse_producer_cmFunction · 0.85
_sse_with_checkpointsFunction · 0.85
_async_stream_jsonlFunction · 0.85

Tested by 3

wrapped_appFunction · 0.68
call_nextFunction · 0.68
_run_asgi_and_cancelFunction · 0.68