开发者

How to stop function if it runs for more than 5 sec?

开发者 https://www.devze.com 2023-03-20 14:48 出处:网络
I have a function which can run for several minutes if server does not respond. I need a method which would limit how long it can run and that it would also give me some kind of boolean feedback if开

I have a function which can run for several minutes if server does not respond.

I need a method which would limit how long it can run and that it would also give me some kind of boolean feedback if开发者_Python百科 it goes over the limit.

EDIT: Script does not look very fancy it is simple function from one project`s API what is why I need to check if it running.

It looks something like this:

<?php
if(isset(theFunction($data)))){ //Some code}
?>

I just need to make theFunction() run for less than 5 sec.

And yes I am working with PHP.

I do not need that script would start over I just want to limit the runtime and skipe it if it exceeds it.


See: http://php.net/manual/en/function.set-time-limit.php

0

精彩评论

暂无评论...
验证码 换一张
取 消