Program stalls when called via Popen4?

Ulrich Petri ulope at gmx.de
Fri Mar 21 00:08:58 CET 2003


"Joshua Pollak" <joshp at cra.com> schrieb im Newsbeitrag
news:Vrqea.6493$io.248058 at iad-read.news.verio.net...
> Hello,
>
> I'm writing an autobuild script for internal use at my company. Its
supposed
> to check our code out of our source control system, call our build system,
> then run our unit tests and email the results to a developer.
>
> Everything seems to be working correctly, EXCEPT that the popen2.Popen4
> instance I'm using to actually build our project never returns. When I
> 'watch' what the subprocess is doing by using 'ps aux', it seems that it
> has stalled on the first call to 'echo'! I'm not sure how to debug this
> because when I try to duplicate the results manually, everything works
> fine.
>
> Here is the relevant code:
>
> compileCommand = self.params["SetupCmd"] + " &&
"+self.params["CompileCmd"]
> compileProcess =  popen2.Popen4(compileCommand)
>

Do you read the output of compileProcess?
If not the buffer of the pipe will fill and then block the child.

You can use something like this:

data = compileProcess.fromchild.read(1)
while 1:
    if data == "":
        ret = compileProcess.poll()
        if ret != -1:
            break
    ret = compileProcess.read(1)


Of course you can increase the amount of data to be read at a time (e.g.
read(100))

Ciao Ulrich






More information about the Python-list mailing list