php GearmanClient timeout
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);
精彩评论