开发者

php GearmanClient timeout

开发者 https://www.devze.com 2023-03-25 02:29 出处:网络
I\'m using the gearman pecl extension in php, and want to have a timeout for a function call. Two use cases: (1) no running workers, (2) worker takes too long to complete

I'm using the gearman pecl extension in php, and want to have a timeout for a function call. Two use cases: (1) no running workers, (2) worker takes too long to complete

If everything is running, the call is very fast, and I want to avoid having an overhead for this timeout.

Code I currently use:

$client = new GearmanClient();
$client->addServer();
$client->do('nonexisti开发者_高级运维ngfunction');


Just call GearmanClient::setTimeout method with number of milliseconds to wait:

$client = new GearmanClient();
$client->addServer();
$client->setTimeout(5000);
0

精彩评论

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

关注公众号