This commit is contained in:
DingZQ
2023-10-21 08:52:26 +08:00
parent 540d726c11
commit adc432b6c1

View File

@@ -150,12 +150,12 @@ app.state.lock = asyncio.Lock() # Create an async lock object
# 必须用这个PlainTextResponse不然每个key都有引号
@app.get("/runproject/", response_class = PlainTextResponse)
async def fastapi_run_project(network: str) -> str:
def fastapi_run_project(network: str) -> str:
if app.state.lock.locked():
raise HTTPException(status_code=400, detail="is in simulation")
else:
try:
await app.state.lock.acquire() # Acquire the lock
app.state.lock.acquire() # Acquire the lock
result = run_project(network)
return result
except asyncio.CancelledError: