Echo from stream_select as output is generated by child process?

From: Date: Thu, 05 Jun 2014 22:18:01 +0000
Subject: Echo from stream_select as output is generated by child process?
Groups: php.general 
Request: Send a blank email to php-general+get-323390@lists.php.net to get a copy of this message
Hi all. This is my first post here. I'm using proc_open to call a python script. The (python) child process takes about a minute to run, and when run from the command line it prints results as they are completed. With the php script, it just prints them all when it's complete. Is there a way to return the python output to the browser in real time? Possibly using more than one stream_select with varying time_outs? The full script is posted on StackOverflow, and what I think are the relevant segments are below: $proc = proc_open ( $child_process , $description , $pipes, glitch_player_DIR, $env ); // set all streams to non blockin mode stream_set_blocking($pipes[1], 0); stream_set_blocking($pipes[2], 0); foreach(array(1, 2) as $desc) { // check stdout for data $read = array($pipes[$desc]); $write = NULL; $except = NULL; $tv = 0; $utv = 50000; $n = stream_select($read, $write, $except, $tv, $utv); if($n > 0) { do { $data = fread($pipes[$desc], 8092); if (is_string($data) && ($data != "")) echo $data ."<br/>"; array_push($glitch_response, $data); } while (strlen($data) > 0); } } Thanks for your feedback. Mike Kilmer mZoo.org

« previous php.general (#323390) next »