Newbie help for using multiprocessing and subprocess packages for creating child processes

Mike Kazantsev mk.fraggod at gmail.com
Wed Jun 17 04:33:55 CEST 2009


On Tue, 16 Jun 2009 23:20:05 +0200
Piet van Oostrum <piet at cs.uu.nl> wrote:

> >>>>> Matt <HellZFury+Python at gmail.com> (M) wrote:
> 
> >M> Try replacing:
> >M>     cmd = [ "ls /path/to/file/"+staname+"_info.pf" ]
> >M> with:
> >M>     cmd = [ “ls”, “/path/to/file/"+staname+"_info.pf" ]
> 
> In addition I would like to remark that -- if the only thing you want
> to do is to start up a new command with subprocess.Popen -- the use
> of the multiprocessing package is overkill. You could use threads as
> well.
> 
> Moreover, if you don't expect any output from these processes and
> don't supply input to them through pipes there isn't even a need for
> these threads. You could just use os.wait() to wait for a child to
> finish and then start a new process if necessary.

And even if there is need to read/write data from/to the pipes more
than once (aka communicate), using threads or any more python
subprocesses seem like hammering a nail with sledgehammer - just _read_
or _write_ to pipes asynchronously.

-- 
Mike Kazantsev // fraggod.net




More information about the Python-list mailing list