Re: Running a code block with timeout

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Wed, Oct 30, 2019 at 8:03 AM Marcos Passos <marcospassos.com@xxxxxxxxx> 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. 

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux