> I'm not sure but from the docs it sounds like os.wait() would
> be called once for each child also, as
If you don't specify a pid os.wait should return as soon as *any*
child process terminates. Which is why it returns the pid - to tell
you which child died...
At least that's what I'd expec
Alan Gauld wrote:
from subprocess import Popen
procs = [ Popen("my-other-script") for i in range(1000) ]
for p in procs:
p.wait()
p.wait will be called for each process in the list so its not quite
the same as a single os.wait but then that might be what's wanted!
I'm not sure but from the docs
> You might like the subprocess module - something like this
(untested!):
Yikes, even more batteries. When did that appear, I've never seen
it before! - Aha! Its 2.4 that's why I havemn't seen it, as ever I
am one release behind the bleeding edge on 2.3...
> from subprocess import Popen
> procs =
> #!/bin/bash
> for i in `seq 1 1000`
> do
> my-other-script &
> done
> wait
> echo "all done"
>
> ...Alternatively, I know I can use os.fork(), os.exec()
> and os.wait() but this seems cumbersome.
Bash is optimised for process control, in that it excels.
For general purpose programming it i
Thanks Pierre & Kent. The subprocess.Popen worked beautifully.
-david
On 4/26/05, Kent Johnson <[EMAIL PROTECTED]> wrote:
> chumpy town wrote:
> > Hello all,
> > I am trying to convert from bash to python for scripting. What is the
> > simplest & cleanest way to do the following in python:
> >
chumpy town wrote:
Hello all,
I am trying to convert from bash to python for scripting. What is the
simplest & cleanest way to do the following in python:
#!/bin/bash
for i in `seq 1 1000`
do
my-other-script &
done
wait
echo "all done"
You might like the subprocess module - something like this
I do not understand why you don't want the so simple fork/exec pattern !
In UNIX programming this is the way to go ...
I cannot think of anything simpler than that :
for i in xrange( 10 ):
pid = os.fork()
if not pid:
os.execv( "/bin/echo", [ "echo", "toto" ] )
try:
while True:
os.wait
Hello all,
I am trying to convert from bash to python for scripting. What is the
simplest & cleanest way to do the following in python:
#!/bin/bash
for i in `seq 1 1000`
do
my-other-script &
done
wait
echo "all done"
I at first tried os.system("my-other-script &") and os.wait() but this
caus