Re: Running a code block with timeout

From: Date: Wed, 30 Oct 2019 12:24:51 +0000
Subject: Re: Running a code block with timeout
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-326932@lists.php.net to get a copy of this message
Hi Aziz, Thank you for your suggestion. We will use it in an API, so good error reporting is a concern for us. We thought about executing the evaluation in a subprocess and use the exit code to report errors. However, this approach has some performance penalties as it requires serializing the input context data and deserializing the result. - Marcos Em qua, 30 de out de 2019 às 09:15, Aziz Saleh <azizsaleh@gmail.com> escreveu: > > On Wed, Oct 30, 2019 at 8:03 AM Marcos Passos <marcospassos.com@gmail.com> > wrote: > >> Hi everyone, >> >> We're looking for a way to run a code block with a timeout. >> >> Our use case involves evaluating an expression written in a custom DSL >> (similar to Symfony Expression Language), and we want to ensure that the >> execution will not exceed a given time limit. >> >> We tried a naive approach using set_time_limit, but there is no way to >> catch the exception from the block code that timed out. We then considered >> using PCNTL, but its use is discouraged production environments. >> >> Do you guys have any suggestions? >> >> - Marcos >> > > If you don't care about the fatal error showing, you can catch the error > using register_shutdown_function() method which will execute that function > for you. >

« previous php.general (#326932) next »