This commit is contained in:
DingZQ
2023-10-21 08:43:17 +08:00
parent bf04c6493f
commit 122b5462a5

View File

@@ -12,6 +12,7 @@ from fastapi.responses import PlainTextResponse
from fastapi.middleware.gzip import GZipMiddleware
from tjnetwork import *
import asyncio
import threading
JUNCTION = 0
RESERVOIR = 1
@@ -145,7 +146,7 @@ async def fastapi_dump_inp(network: str, inp: str) -> bool:
dump_inp(network, inp)
return True
lock = asyncio.Lock()
lock = threading.Lock()
# 必须用这个PlainTextResponse不然每个key都有引号
@app.get("/runproject/", response_class = PlainTextResponse)
@@ -154,7 +155,7 @@ async def fastapi_run_project(network: str) -> str:
raise HTTPException(status_code=400, detail="is in simulation")
else:
try:
async with lock:
with lock:
result = run_project(network)
return result
except asyncio.CancelledError: