Python Forum

Full Version: SOLVED: best way to block (wait on) shell calls to multiple windows programs at once?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
EDIT: turns out start (in windows) has a /wait option, which i can append to solve this. ive known start longer than ive known python, but i didnt know about that option.


so i have this program, and im happy to post the source but its quite large (it has function calls that are literally 1000 loc distance from the defintion) and im not looking for someone to fix the code; im looking for practical design advice.

what the code (already) does is:

* get a list of files piped into stdin.

* get sys.argv[2] ([1] is already used for something else) as a string

* run sys.argv[2] + " " + (each line of stdin) using os.system

i know, you want me to use subprocess. thats fine. heres my question though:


if you are a very silly and pipe 1000 filenames to this feature, and then say give it windows notepad as the second command line argument...

its going to open 1000 instances of notepad.

if you do the same thing with leafpad in gnu/linux, youre ok! because the shell wont continue until leafpad closes.

but windows wont block the loop, so it will just keep opening more notepads.

i can think of one really easy fix for this, i bet you can too, the only reason im putting this question here is:

...have you got a better idea than the one thats easy to think of? im open to advice here.

and yes, i know, i should be using subprocess. that doesnt address the question though, because (as far as i know) subprocess wont fix this UNLESS you can tell me how it would, actually-- please do feel free to explain how.