Unverified Commit e3dc66e8 authored by Marvin Meiers's avatar Marvin Meiers
Browse files

symphony: fix sending of console lines

parent c9ab808d
...@@ -451,6 +451,6 @@ class RunnerClient: ...@@ -451,6 +451,6 @@ class RunnerClient:
"stderr": stderr, "stderr": stderr,
"output": line, "output": line,
} }
objs.append[obj] objs.append(obj)
async with self.post(url=f"/{run_id}/console", json=objs) as resp: async with self.post(url=f"/{run_id}/console", json=objs) as resp:
ret = await resp.json() ret = await resp.json()
...@@ -37,7 +37,7 @@ verbose = True ...@@ -37,7 +37,7 @@ verbose = True
# TODO: FIXME, create a custom listener for the runner to register + create backend endpoint to update the output etc. # TODO: FIXME, create a custom listener for the runner to register + create backend endpoint to update the output etc.
async def periodically_update(rc: client.RunnerClient, run_id: int, async def periodically_update(rc: client.RunnerClient, run_id: int,
listeners: list[tuple[str, simulation_executor.SimulationSimpleRunner]]) -> None: listeners: list[tuple[str, command_executor.LegacyOutputListener]]) -> None:
try: try:
while True: while True:
all_out: list[str] = [] all_out: list[str] = []
...@@ -55,7 +55,8 @@ async def periodically_update(rc: client.RunnerClient, run_id: int, ...@@ -55,7 +55,8 @@ async def periodically_update(rc: client.RunnerClient, run_id: int,
await rc.update_run(run_id, "running", json.dumps(all_out)) await rc.update_run(run_id, "running", json.dumps(all_out))
for sim_out in sim_outs: for sim_out in sim_outs:
await rc.send_out(run_id, sim_out[0], sim_out[1], sim_out[2]) if len(sim_out[2]) > 0:
await rc.send_out(run_id, sim_out[0], sim_out[1], sim_out[2])
await asyncio.sleep(0.5) await asyncio.sleep(0.5)
...@@ -77,11 +78,12 @@ async def run_instantiation(sc: client.SimBricksClient, rc: client.RunnerClient, ...@@ -77,11 +78,12 @@ async def run_instantiation(sc: client.SimBricksClient, rc: client.RunnerClient,
listeners.append((sim.name, listener)) listeners.append((sim.name, listener))
update_task = asyncio.create_task(periodically_update(rc=rc, run_id=run_id, listeners=listeners)) update_task = asyncio.create_task(periodically_update(rc=rc, run_id=run_id, listeners=listeners))
output = await runner.run() d, p = await asyncio.wait([asyncio.create_task(runner.run()), update_task], return_when=asyncio.FIRST_COMPLETED)
update_task.cancel() for pending in p:
pending.cancel()
output_path = inst.get_simulation_output_path() output_path = inst.get_simulation_output_path()
output.dump(outpath=output_path) list(d)[0].result().dump(outpath=output_path)
if inst.create_artifact: if inst.create_artifact:
art.create_artifact( art.create_artifact(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment