()
| 311 | res_fut = cast(Future, result_future) |
| 312 | |
| 313 | async def non_streaming_monitor_fn(): |
| 314 | nonlocal client_disconnected_early |
| 315 | while not res_fut.done(): |
| 316 | if GlobalState.IS_SHUTTING_DOWN.is_set(): |
| 317 | res_fut.cancel() |
| 318 | break |
| 319 | if not await _test_client_connection( |
| 320 | req_id, http_request |
| 321 | ): |
| 322 | client_disconnected_early = True |
| 323 | res_fut.set_exception( |
| 324 | HTTPException( |
| 325 | status_code=499, |
| 326 | detail="Client disconnected", |
| 327 | ) |
| 328 | ) |
| 329 | break |
| 330 | await asyncio.sleep(0.3) |
| 331 | |
| 332 | disconnect_monitor_task = asyncio.create_task( |
| 333 | non_streaming_monitor_fn() |
no test coverage detected