From bf04c6493f8b6baf41ac2e0a740fea8f4e29c64f Mon Sep 17 00:00:00 2001 From: DingZQ Date: Sat, 21 Oct 2023 00:14:22 +0800 Subject: [PATCH] Refine --- main.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index c8cb70b..25bdcb6 100644 --- a/main.py +++ b/main.py @@ -34,8 +34,6 @@ if not os.path.exists(tmpDir): app = FastAPI() -lock = asyncio.Lock() - app.add_middleware(GZipMiddleware, minimum_size=1000) ############################################################ @@ -147,10 +145,11 @@ async def fastapi_dump_inp(network: str, inp: str) -> bool: dump_inp(network, inp) return True +lock = asyncio.Lock() + # 必须用这个PlainTextResponse,不然每个key都有引号 @app.get("/runproject/", response_class = PlainTextResponse) async def fastapi_run_project(network: str) -> str: - global lock if lock.locked(): raise HTTPException(status_code=400, detail="is in simulation") else: