PHP protocol timeout

I am using the gearman pecl extension in php and want to have a timeout to call a function. Two use cases: (1) there are no working workers, (2) the employee takes too much time to complete

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

Currently using code I:

$client = new GearmanClient();
$client->addServer();
$client->do('nonexistingfunction');
+5
source share
1 answer

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

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

All Articles