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都有引号
|
||||
@app.get("/runproject/", response_class = PlainTextResponse)
|
||||
async def fastapi_run_project(network: str) -> str:
|
||||
global lock_simulation
|
||||
|
||||
print('lock simulation')
|
||||
print(lock_simulation.value)
|
||||
|
||||
if lock_simulation.value == 1:
|
||||
filename = 'lock.simulation'
|
||||
if os.path.exists(filename):
|
||||
raise HTTPException(status_code=409, detail="is in simulation")
|
||||
|
||||
with lock_simulation.get_lock():
|
||||
lock_simulation.value = 1
|
||||
else:
|
||||
f = open(filename, "w")
|
||||
f.write("locksimulaiton")
|
||||
f.close()
|
||||
result = run_project(network)
|
||||
lock_simulation.value = 0
|
||||
os.remove(filename)
|
||||
return result
|
||||
|
||||
# put in inp folder, name without extension
|
||||
|
||||
Reference in New Issue
Block a user