Refine
This commit is contained in:
17
main.py
17
main.py
@@ -153,18 +153,15 @@ async def fastapi_dump_inp(network: str, inp: str) -> bool:
|
|||||||
# 必须用这个PlainTextResponse,不然每个key都有引号
|
# 必须用这个PlainTextResponse,不然每个key都有引号
|
||||||
@app.get("/runproject/", response_class = PlainTextResponse)
|
@app.get("/runproject/", response_class = PlainTextResponse)
|
||||||
async def fastapi_run_project(network: str) -> str:
|
async def fastapi_run_project(network: str) -> str:
|
||||||
global lock_simulation
|
filename = 'lock.simulation'
|
||||||
|
if os.path.exists(filename):
|
||||||
print('lock simulation')
|
|
||||||
print(lock_simulation.value)
|
|
||||||
|
|
||||||
if lock_simulation.value == 1:
|
|
||||||
raise HTTPException(status_code=409, detail="is in simulation")
|
raise HTTPException(status_code=409, detail="is in simulation")
|
||||||
|
else:
|
||||||
with lock_simulation.get_lock():
|
f = open(filename, "w")
|
||||||
lock_simulation.value = 1
|
f.write("locksimulaiton")
|
||||||
|
f.close()
|
||||||
result = run_project(network)
|
result = run_project(network)
|
||||||
lock_simulation.value = 0
|
os.remove(filename)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
# put in inp folder, name without extension
|
# put in inp folder, name without extension
|
||||||
|
|||||||
Reference in New Issue
Block a user