Using subprocess module to launch a shell shell script that itself forks a process

Samuel A. Falvo II sam.falvo at gmail.com
Wed Oct 8 14:24:39 EDT 2008


On Oct 7, 6:23 pm, "Gabriel Genellina" <gagsl-... at yahoo.com.ar> wrote:
> Is your shell script doing something else, apart from invoking the java  
> process?

Obviously, yes.  The script is some 150 lines long.  But the hang-up
occurs because of the forked Java process, not the other lines.

> If not, you could just invoke java directly from Python. Also,  
> you set stdin=PIPE - is your java process expecting some input? you're not  
> writing anything to stdin.

It does not expect input from stdin.  However, this does not affect
any OTHER scripts or commands I run.

Let's remember to look at the objective facts: for shell scripts that
launch child processes of their own, Python hangs.  For all other
types of commands, it works 100% as expected.

> Anyway, it's better to use the communicate method instead (it uses select  
> to read from both stdout and stderr):

That doesn't help me.

> See  http://docs.python.org/library/subprocess.html#subprocess.Popen.commu...

I have.



More information about the Python-list mailing list