php GearmanClient超时

问题描述 投票:5回答:1

我在php中使用gearman pecl扩展,并希望函数调用超时。两个用例:(1)没有正在运行的工人,(2)工人需要很长时间才能完成

如果一切都在运行,那么调用速度非常快,我希望避免此超时的开销。

我目前使用的代码:

$client = new GearmanClient();
$client->addServer();
$client->do('nonexistingfunction');
php gearman
1个回答
0
投票

只需要等待毫秒数的GearmanClient::setTimeout方法:

$client = new GearmanClient();
$client->addServer();
$client->setTimeout(5000);
© www.soinside.com 2019 - 2024. All rights reserved.