spawning a separate process

Padraig at Linux.ie Padraig at Linux.ie
Tue Apr 1 08:14:48 EST 2003


Mark Light wrote:
> Hi,
>        I have a python program from which I wish to spawn an os.system call
> (a bash script) that may take several minutes to run - whilst the rest of
> the script carries on. I have tried using bits of code from books - but it
> never seem to work quite right

how about using the popen2.Popen3 class?
something like:

import popen2
child=popen2.Popen3("mycommand")
while 1:
     if child.poll() == -1:
         #child not finished yet
     do other stuff

note the module is implemented in python
so you can look at it in your distribution.

Pádraig.





More information about the Python-list mailing list