Possible Duplicate:
How can I stop PHP sleep() affecting my whole PHP code?
PHP: Output data before and after sleep()?
I have a php code in localhost which echo's data and sleeps in between. On the client side, I am able to see the data received in timely manner and I also render it.
$condition = true;
while($condition) {
$data = get_some_data(); // may not fetch new data to be sent, each iteration.
echo $data;
ob_flush();
$i++;
sleep(1);
$condition = run_some_logic(); //could become false depending on DB value
}
But, when I open another browser and try to open another page (localhost again) , it is not even opening. When I close the first window and try to open the second URL after some time, it is working.
I think clearly this has to do with sleep. Is there a way to call sleep() or output data in intervals, without blocking all other requests?
What I am trying to do here is, not let the loop finish until a condition is satisfied.