just the basic: $description = array ( 0 => array("pipe", "r"), // stdin 1 => array("pipe", "w"), // stdout 2 => array("pipe", "w") // stderr ); On Jun 5, 2014, at 5:25 PM, Aziz Saleh wrote: > On Thu, Jun 5, 2014 at 6:18 PM, Mike Kilmer <mike@xxxxxxxxxxxx> wrote: > >> 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 > > > What do you have for your descriptor array (second param on proc_open)? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php