Re: [PHP-DEV] Graceful timeout

2020-05-18 Thread Johannes Schlüter
On Sat, 2020-05-16 at 19:15 +0100, Derick Rethans wrote: > sleep(2) should not trigger a 1 second timeout. Currently the time > counted for max_execution_time timeouts is CPU time, not wall time. I might remember wrongly, but I think on Windows it uses wall time. One thing to consider when carin

Re: [PHP-DEV] Graceful timeout

2020-05-16 Thread Jakob Givoni
On Sat, 16 May 2020 at 19:42, David Rodrigues wrote: > Hello! > > Currently we can use set_time_limit() to specify that our script will run > by some seconds before we get "fatal error: maximum execution time of 1 > second exceeded". And we can't catch it and keep running. > > I believe that it i

Re: [PHP-DEV] Graceful timeout

2020-05-16 Thread Niklas Keller
Hey David, I guess you're looking for a preemptive timeout. I guess an alarm signal and PHP's async signal handling will be your best bet here. In case you're looking for a cooperative timeout, https://amphp.org/ and it's `Amp\Promise\timeout()` / `TimeoutCancellationToken` might be helpful. Bes

Re: [PHP-DEV] Graceful timeout

2020-05-16 Thread tyson andre
Hi David, > You can probably implement this already with PHP's tick functionality (https://www.php.net/manual/en/function.register-tick-function.php), as > long as the code in the anonymous function does PHP statements/function > calls. > > If your problem is waiting for an external resource to

Re: [PHP-DEV] Graceful timeout

2020-05-16 Thread Derick Rethans
Hi David, On Sat, 16 May 2020, David Rodrigues wrote: > Currently we can use set_time_limit() to specify that our script will > run by some seconds before we get "fatal error: maximum execution time > of 1 second exceeded". And we can't catch it and keep running. You can set-up a shutdown hand