(self, scope: Scope, receive: Receive, send: Send)
| 206 | await response(scope, receive, send) |
| 207 | |
| 208 | async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None: |
| 209 | # Handle lifespan events (startup/shutdown) |
| 210 | |
| 211 | if scope["type"] == "lifespan": |
| 212 | try: |
| 213 | dash_app = get_app() |
| 214 | dash_app.backend._setup_catchall() |
| 215 | except Exception: # pylint: disable=broad-exception-caught |
| 216 | traceback.print_exc() |
| 217 | await self._initialize_dev_tools() |
| 218 | await self.app(scope, receive, send) |
| 219 | return |
| 220 | |
| 221 | # Non-HTTP/WebSocket scopes pass through |
| 222 | if scope["type"] != "http": |
| 223 | await self.app(scope, receive, send) |
| 224 | return |
| 225 | |
| 226 | # Non-Dash routes pass through to avoid consuming body stream |
| 227 | path = scope["path"] |
| 228 | prefix = self.dash_app.config.routes_pathname_prefix |
| 229 | dash_prefix = prefix.rstrip("/") + "/_dash-" |
| 230 | if ( |
| 231 | not path.startswith(dash_prefix) |
| 232 | and path != prefix |
| 233 | and path != prefix.rstrip("/") |
| 234 | ): |
| 235 | await self.app(scope, receive, send) |
| 236 | return |
| 237 | |
| 238 | # HTTP request handling |
| 239 | request = Request(scope, receive=receive) |
| 240 | token = set_current_request(request) |
| 241 | |
| 242 | try: |
| 243 | await self._setup_timing(request) |
| 244 | await self._run_before_hooks() |
| 245 | |
| 246 | await self.app(scope, receive, send) |
| 247 | |
| 248 | await self._run_after_hooks() |
| 249 | self._finalize_timing(request) |
| 250 | |
| 251 | except Exception as e: # pylint: disable=W0718 |
| 252 | await self._handle_error(e, scope, receive, send) |
| 253 | finally: |
| 254 | reset_current_request(token) |
| 255 | |
| 256 | |
| 257 | class FastAPIDashServer(BaseDashServer[FastAPI]): |
nothing calls this directly
no test coverage detected