php GearmanClient超时

Nik*_*ams 5 php gearman

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

如果一切正在运行,那么调用非常快,我想避免这个超时的开销.

我目前使用的代码:

$client = new GearmanClient();
$client->addServer();
$client->do('nonexistingfunction');
Run Code Online (Sandbox Code Playgroud)

小智 0

只需调用GearmanClient::setTimeout方法并指定要等待的毫秒数:

$client = new GearmanClient();
$client->addServer();
$client->setTimeout(5000);
Run Code Online (Sandbox Code Playgroud)

  • 我认为这是与 gearman 守护进程的 I/O 通信超时,对解决我的问题没有帮助。 (3认同)