From 48cdf8f0dd3d9a2180ffae6be6200031a0964e85 Mon Sep 17 00:00:00 2001 From: DingZQ Date: Sat, 14 Oct 2023 16:21:43 +0800 Subject: [PATCH] Check isSimulation value when try to run simulation --- main.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 515bc45..075a2ca 100644 --- a/main.py +++ b/main.py @@ -1,6 +1,7 @@ import os import io import json +import time from typing import * from urllib.request import Request from xml.dom import minicompat @@ -143,10 +144,21 @@ async def fastapi_dump_inp(network: str, inp: str) -> bool: dump_inp(network, inp) return True +isSimulaion = False # 必须用这个PlainTextResponse,不然每个key都有引号 @app.get("/runproject/", response_class = PlainTextResponse) async def fastapi_run_project(network: str) -> str: - return run_project(network) + for i in range(10000): + if isSimulaion == False: + break + time.sleep(5) + + result = {} + if isSimulaion == False: + result = run_project(network) + isSimulaion = False + + return result # put in inp folder, name without extension @app.get("/runinp/")