How To Automate Data Gathering And Not Freeze In 10%
What I have: (take a look or fire on localhost if required: http://pastebin.com/virLR7dF) (take a look on image presenting my case: http://iv.pl/images/47143498348127804676.png) I
Solution 1:
Output Buffering might be helping you in PHP
ob_start This function will turn output buffering on. While output buffering is active no output is sent from the script (other than headers), instead the output is stored in an internal buffer.
ob_flush This function will send the contents of the output buffer (if any)
Solution 2:
There's some things that may cause problems when doing this.
1) An error gets triggered inside the loop and the script stops executing.
Answer : turn errors into exceptions which is catchable
2) You exceed the time limit.
Solution: Set the time limit to zero
Example:
set_error_handler(function($errno, $errstr, $errfile, $errline) {
if($errno != E_STRICT && $errno != E_DEPRECATED && $errno != E_NOTICE) {
thrownewException($errstr.' in '.$errfile.' on line '.$errline);
}
returnfalse;
});
set_time_limit(0);
functionmy_loop_func() {
// do what ever...
}
while(true) {
try {
my_loop_func();
}
catch(Exception$e) {
// write some log message here might be good
}
sleep(10);
}
Post a Comment for "How To Automate Data Gathering And Not Freeze In 10%"