Re: Echo from stream_select as output is generated by child process?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 6-6-2014 0:18, Mike Kilmer 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?


This actually sounds like the issue is not in your actual PHP script itself (or at least not in the proc-part) but rather in the fact that your server waits until the script has finished and then sends the entire output in one go to the client.

So... there are 2 things you should do:
1. make sure you're not buffering the output (ie. call ob_end_flush() at the start of your script to make sure output-buffering is turned off)

2. Configure your server to send continuous chunked output. How heavily depends on your server. You could for example opt to use chunked-encoding. This thread on stackoverflow may help: http://stackoverflow.com/questions/4809774/transfer-encoding-chunked-header-in-php

- Tul



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux