Re: What happens when the execution time limit is exceeded?
| From: | Tim Streater | Date: | Thu, 06 Mar 2014 14:13:00 +0000 |
| Subject: | Re: What happens when the execution time limit is exceeded? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-323043@lists.php.net to get a copy of this message | ||
On 06 Mar 2014 at 14:02, Christoph Becker <cmbecker69@gmx.de> wrote:
> Tim Streater wrote:
>
>> It would seem that exceeding the execution time can be caught by
>> declaring a handler with set_error_handler. However, even though I'm
>> sure I've read something about it somewhere, I can't now find any
>> info about what happens next. Specifically, inside my error handler,
>> how long does the error handler then have to clean up? Can I do
>> set_time_limit() again and return? (not that I'm minded to, but it
>> might be useful to someone).
>>
>> I seem to have enough time to output some stuff back to the browser
>> and log an error message or two, but it might be useful to know the
>> actual limits.
>
> You can't catch a timeout with set_error_handler(), because it is a
> fatal error. The only option you have is using
> register_shutdown_function() (which does not allow to return). It seems
> that the registered shutdown function resets the timeout once.
Ah, thanks. My shutdown_function in fact calls my error_handler, so that explains it.
> Anyway, it seems better to prolong the timeout limit by calling
> set_time_limit() in advance, when you're expecting a long execution time.
Oddly enough :-) that's actually what I do. But understanding what happens is important.
--
Cheers -- Tim