Skip to content

Commit fb60e48

Browse files
Flynn-ZhCopilot
andauthored
Update mineru/cli/fast_api.py
Co-authored-by: Copilot <[email protected]>
1 parent 5a551fe commit fb60e48

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

mineru/cli/fast_api.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,17 @@
2828
# 并发控制依赖函数
2929
async def limit_concurrency():
3030
if _request_semaphore is not None:
31-
if _request_semaphore.locked():
31+
try:
32+
await asyncio.wait_for(_request_semaphore.acquire(), timeout=0.0)
33+
except asyncio.TimeoutError:
3234
raise HTTPException(
3335
status_code=503,
3436
detail="Server is at maximum capacity. Please try again later."
3537
)
36-
async with _request_semaphore:
38+
try:
3739
yield
40+
finally:
41+
_request_semaphore.release()
3842
else:
3943
yield
4044

0 commit comments

Comments
 (0)