@@ -56,8 +56,7 @@ async def run(
5656 for cmd in cmds :
5757 log .debug (
5858 "launching cmd:\n \" {}\" \n " .format (cmd ))
59- # proc = await trio.open_process(
60- proc = trio .Process (
59+ proc = await trio .open_process (
6160 shlex .split (cmd ),
6261 stdout = subprocess .DEVNULL ,
6362 stderr = subprocess .PIPE
@@ -157,32 +156,32 @@ def clear(self):
157156 self ._procs .clear ()
158157
159158
160- async def run_all_agents (runner , agents , timeout = 180 ):
161- """Run a sequencec of agents using a ``TrioRunner``.
162- """
163- async def finalize ():
164- # this might raise TimeoutError
165- cmds2procs = await runner .get (timeout = timeout )
166- agents2procs = list (zip (agents , cmds2procs .values ()))
167- msg = report .err_summary (agents2procs )
168- if msg :
169- # report logs and stderr
170- await report .emit_logfiles (agents2procs )
171- raise SIPpFailure (msg )
172-
173- return cmds2procs
159+ async def run_all_agents (runner , agents , timeout = 180 , block = True ):
160+ """Run a sequencec of agents using a ``TrioRunner``."""
174161
175162 try :
176- await runner .run (
177- (ua .render () for ua in agents ),
178- timeout = timeout
179- )
180- await finalize ()
163+ await runner .run ((ua .render () for ua in agents ), timeout = timeout )
164+ if block :
165+ await finalize (runner , agents , timeout )
181166 return runner
182167 except TimeoutError as terr :
183168 # print error logs even when we timeout
184169 try :
185- await finalize ()
170+ await finalize (runner , agents , timeout )
186171 except SIPpFailure as err :
187- assert ' exit code -9' in str (err )
172+ assert " exit code -9" in str (err )
188173 raise terr
174+
175+
176+ async def finalize (runner , agents , timeout ):
177+ """Block up to `timeout` seconds for all agents to complete."""
178+ # this might raise TimeoutError
179+ cmds2procs = await runner .get (timeout = timeout )
180+ agents2procs = list (zip (agents , cmds2procs .values ()))
181+ msg = report .err_summary (agents2procs )
182+ if msg :
183+ # report logs and stderr
184+ await report .emit_logfiles (agents2procs )
185+ raise SIPpFailure (msg )
186+
187+ return cmds2procs
0 commit comments