@@ -213,18 +213,25 @@ async def run_command(self, cmd, input=None, env=None):
213
213
try :
214
214
out , eout = await proc .communicate (input = inbytes )
215
215
except :
216
- self .log .debug ("Exception raised when trying to run command: %s" % command )
216
+ self .log .debug ("Exception raised when trying to run command: %s" % cmd )
217
217
proc .kill ()
218
- self .log .debug ("Running command failed done kill" )
219
- out , eout = await proc .communicate ()
220
- out = out .decode .strip ()
221
- eout = eout .decode .strip ()
222
- self .log .error ("Subprocess returned exitcode %s" % proc .returncode )
223
- self .log .error ('Stdout:' )
224
- self .log .error (out )
225
- self .log .error ('Stderr:' )
226
- self .log .error (eout )
227
- raise RuntimeError ('{} exit status {}: {}' .format (cmd , proc .returncode , eout ))
218
+ self .log .debug ("Running command failed, killed process." )
219
+ try :
220
+ out , eout = await asyncio .wait_for (proc .communicate (), timeout = 2 )
221
+ out = out .decode ().strip ()
222
+ eout = eout .decode ().strip ()
223
+ self .log .error ("Subprocess returned exitcode %s" % proc .returncode )
224
+ self .log .error ('Stdout:' )
225
+ self .log .error (out )
226
+ self .log .error ('Stderr:' )
227
+ self .log .error (eout )
228
+ raise RuntimeError ('{} exit status {}: {}' .format (cmd , proc .returncode , eout ))
229
+ except asyncio .TimeoutError :
230
+ self .log .error ('Encountered timeout trying to clean up command, process probably killed already: %s' % cmd )
231
+ return ""
232
+ except :
233
+ self .log .error ('Encountered exception trying to clean up command: %s' % cmd )
234
+ raise
228
235
else :
229
236
eout = eout .decode ().strip ()
230
237
err = proc .returncode
0 commit comments