1

I am running a command with python3.4 subprocess. The command has 2 options, one standard and one interactive. The problem is that if I run it in the standard mode check_process returns immediately. I have also checked running it with subprocess.call and then running the command in both modes takes longer. In summary

subprocess.check_output([command]) //returns immediately
subprocess.check_output([command, "-i"]) // takes longer to run, returns output
subprocess.call([command]) // also takes longer to run

The command is running a go program, in which in case of the non interactive mode, I disable the output. Is it possible that because of this check_output returns immediately? From the documentation I understood that it's supposed to wait for the subprocess to return.

I have checked running the command from outside of the python script and in both interactive and standard mode it takes "a bit" to run.

Ela
  • 3,142
  • 6
  • 25
  • 40

1 Answers1

0

If check_output() has returned; it means the child process is not running. Moreover if check_output() doesn't raise an exception then it means that the child process has returned with a zero exit status (it indicates success in many cases).

A command may change its behavior depending on whether it thinks it is run interactively in a terminal or not e.g., Q: Why not just use a pipe (popen())?
What exactly are the changes depends on a particular command e.g., apt-get stops reporting progress when stdout is redirected.

Community
  • 1
  • 1
jfs
  • 399,953
  • 195
  • 994
  • 1,670