Re: What happens when the execution time limit is exceeded?
| From: | Christoph Becker | Date: | Thu, 06 Mar 2014 14:02:04 +0000 |
| Subject: | Re: What happens when the execution time limit is exceeded? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-323042@lists.php.net to get a copy of this message | ||
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.
Anyway, it seems better to prolong the timeout limit by calling
set_time_limit() in advance, when you're expecting a long execution time.
--
Christoph M. Becker