python 2.6.5, and getting the result of a call to a php app
<p>i've got this snazzy python code:</p>

<pre><code>import subprocess
value = subprocess.Popen(["php","./php/php_runner.php"],stdout=subprocess.PIPE);
</code></pre>

<p>the problem is, i have no idea how to check if the php_runner, well, ran. Currently, it has the following salient sections:</p>

<pre><code>if (count($argv) != 4){
    die("four arguments are needed\n");
}
</code></pre>

<p>and</p>

<pre><code>$returnValue =  call_to_another_php_class();
return $returnValue;
</code></pre>

<p>So what i want is this:</p>

<ol>
<li><p>How do i get the return value, whatever it may be, using python? </p></li>
<li><p>You probably are going to tell me to use  "PIPE" in the answer, but the (to me, incomprehensible) python docs (http://docs.python.org/library/subprocess.html) state:</p>

<blockquote>
  <p>Do not use stdout=PIPE or stderr=PIPE with this function. As the pipes are not being read in >the current process, the child process may block if it generates enough output to a pipe to fill up >the OS pipe buffer.
  So what do i use then, because while I don't really know what they're barking on about, i sit up and take note about notes in grey boxes. Pity they didn't spell out what i'm meant to do - but, well, what am i meant to do?</p>
</blockquote></li>
<li>the "returnValue" that my php code returns, is <em>that</em> what python is going to pickup as the return value from the function? If not, how do i return that value?</li>
</ol>

<p>cheers!</p>

<p>UPDATE</p>

<p>Thanks to the given answer, here's the changes i made:</p>

<ol>
<li>edited <code>/etc/php5/cli/conf.d/mcrypt.ini</code> (actually, this is just a change for ubuntu 10.04, and I changed the first line to begin with a ; instead of a #. That stopped an annoying "we don't like #" error that kept popping up)</li>
<li><p>in my php, I changed the code to read:</p>

<pre><code>if (count($argv) != 4){
    fwrite(STDERR, "four arguments are needed\n");
    exit(1); // A response code other than 0 is a failure
}
</code></pre>

<p>this puts my error value as an error. the die() command wasn't doing that for me.</p></li>
<li><p>changed the python to read:</p>

<pre><code>value = subprocess.Popen(["php","./php/php_runner.php"],stdout=subprocess.PIPE,   
stderr=subprocess.PIPE);
print value.communicate();
</code></pre>

<p>Yeah, realistically, i'd do an if on value.communicate()[1], becase that is where the errors are.</p></li>
<li><pre><code>$returnValue =  call_to_another_php_class();
if ($returnValue == 1){ //hah, php has a good return value as 1.
    //no problem
} else {
    fwrite(STDERR,get_error_from_php_class());
    exit(1);
}
</code></pre></li>
</ol>

<p>booyah!</p>
