PHP script seems to crash during sleep command
I've got a php script that queries an external API that allows a limited amount of queries in a time period. To handle this I sleep my script for 60 seconds if I get a message back that I've hit this limit and then wake up and check again then repeat this until I can get more data back from the API.
The problem seems to be that sometimes during that sl开发者_如何学Ceep (somewhat rarely) the script will either crash, or never return. I'm not certain which yet all I can tell is that the script it doesn't pick back up and restart processing.
I'm looking for any tips or ideas on what could be happening so I have an idea of what to look for to fix this.
Thanks.
Can you post some of the code?
Since you are not sure if the script is crashing or never returning, it is possible that there is another area of your script that isn't hitting the sleep command, and just finishes executing.
check the max execution time in php.ini
$time=ini_get('max_execution_time');
$slept=0;
while(!dataready()){
sleep(1);
$slept++;
if($slept>=$time-4) die("script timed out");
}
精彩评论