async context manager for connection manager
()
| 314 | |
| 315 | @asynccontextmanager |
| 316 | async def connection_manager(): |
| 317 | """ |
| 318 | async context manager for connection manager |
| 319 | """ |
| 320 | try: |
| 321 | await asyncio.wait_for(connection_semaphore.acquire(), timeout=0.001) |
| 322 | yield |
| 323 | except asyncio.TimeoutError: |
| 324 | api_server_logger.info(f"Reach max request concurrency, semaphore status: {connection_semaphore.status()}") |
| 325 | raise HTTPException( |
| 326 | status_code=429, detail=f"Too many requests,current max concurrency is {args.max_concurrency}" |
| 327 | ) |
| 328 | |
| 329 | |
| 330 | # TODO 传递真实引擎值 通过pid 获取状态 |
no test coverage detected