python - catch the exception of a subprocess called by another function -
I want to automate a script execution on a subprocess, so I use subprocess
lib I am doing thread and schedule
lib to schedule it to be created.
I would like to verify that the script executed remotely is working without issues when I give script 1 (error) or when script_file
is absent Whoever was trying does not print any error (and if I am not mistaken, by adding exception casing, kills subprocess and its work)
All tips are welcome, we do not have INP wrapper target, but there is also a good solution to verify the execution of the defined
method.
Use subprocess. POPIN ()
Run cmd = popon (sCmd, shell = true, stdout = PIPE, stderr = PIPE) in RunCmd.stdout for sLine: print (sLine.decode ( )) Stdout.flush () in aLog.append (sLine.decode ()) for RunCmd.stderr in sLine: print (sLine.decode ()) stderr.flush () aErrorLog append (sLine.decode ()) RunCmd. Wait () RunCmd.returncode == 0: Run RunCmd.wait () else: Run RunCmd.returncode
RunCmd.wait () Wait for the process to finish, and the process The code will return (for succuss or failure) also prints the output on realtime.
Comments
Post a Comment