Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have few very-long-executing scripts, and my max_execution_time is 5

However, when I was taking some information from plus.google.com, it took about five minutes. It all worked well but it was just time-eating proccess, after those five minutes, it died on max_execution_time limit.

My question is -> how is that possible? Is max_execution_time counted only when NOTHING happends (or for example a lot of things a lot of times (infinite loop)) ?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

It starts to count when you start execution; the reason why the script doesn't die until the call to google returns is that the timer isn't checked while a syscall is in progress, but when the syscall returns, PHP looks at the timer and goes "oh, you're out of time" and terminates the script.

share|improve this answer
    
so if curl_exec took more than 5 seconds, it's executed (for example in 39 seconds) and then php dies ? –  genesis Jul 15 '11 at 12:46
1  
Yes, exactly... –  womble Jul 15 '11 at 12:49

The counter is only checked when the thread of execution is within PHP - when the process is sleeping (waiting for blocking I/O) it can't check the clock. This also occurs if the thread of execution goes into an extension and stays there for some time.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.