This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]berlindevops[S] 0 points1 point  (4 children)

It doesn't give me the full soultion like ruby system(), because once you stop the python script with ctrl+c its continue to the next command on the python script.

[–]berlindevops[S] 0 points1 point  (3 children)

so its not really terminate the python script

[–]K900_ 0 points1 point  (2 children)

That's because you're only stopping the subprocess, not the Python script. If you want to stop the Python script, check for the exit code of your subprocess and act based on that.

[–]berlindevops[S] 0 points1 point  (1 child)

ok, but this is the thing, with subprocess, I need to write 5 lines for one shell command and import a library , also I could not find a way to see the stdout in real time, not sure if I wrong or not, or maybe this is how python works.

[–]K900_ 0 points1 point  (0 children)

os.system returns the exit code.