Re: Echo from stream_select as output is generated by child process?
| From: | Maciek Sokolewicz | Date: | Thu, 05 Jun 2014 23:06:40 +0000 |
| Subject: | Re: Echo from stream_select as output is generated by child process? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-323394@lists.php.net to get a copy of this message | ||
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