()
| 271 | comp_ev = cast(Event, completion_event) |
| 272 | |
| 273 | async def enhanced_disconnect_monitor_fn(): |
| 274 | nonlocal client_disconnected_early |
| 275 | disco_count = 0 |
| 276 | while not comp_ev.is_set(): |
| 277 | if GlobalState.IS_SHUTTING_DOWN.is_set(): |
| 278 | comp_ev.set() |
| 279 | break |
| 280 | if ( |
| 281 | GlobalState.IS_QUOTA_EXCEEDED |
| 282 | and not GlobalState.IS_RECOVERING |
| 283 | ): |
| 284 | # Abort if quota exceeded and not recovering |
| 285 | client_disconnected_early = True |
| 286 | comp_ev.set() |
| 287 | break |
| 288 | |
| 289 | if not await _test_client_connection( |
| 290 | req_id, http_request |
| 291 | ): |
| 292 | disco_count += 1 |
| 293 | if disco_count >= 3: |
| 294 | client_disconnected_early = True |
| 295 | comp_ev.set() |
| 296 | break |
| 297 | else: |
| 298 | disco_count = 0 |
| 299 | await asyncio.sleep(0.2) |
| 300 | |
| 301 | disconnect_monitor_task = asyncio.create_task( |
| 302 | enhanced_disconnect_monitor_fn() |
no test coverage detected