Closed microlancer closed 1 year ago
Added PR for this feature
To avoid getting a fatal error from PHP, I putt my $worker->addServer() call inside of a try catch block and it helps, however, I still never get inside of the catch (Throwable) (I've tried with Throwable, Error, Exception, etc). Is that a problem with Gearman or am I missing/not understanding something.
To avoid getting a fatal error from PHP, I putt my $worker->addServer() call inside of a try catch block and it helps, however, I still never get inside of the catch (Throwable) (I've tried with Throwable, Error, Exception, etc). Is that a problem with Gearman or am I missing/not understanding something.
I don't think this question is relevant to this issue. addServer()
returns true or false, so you use it like this:
if ($worker->addServer($host, $port) !== true) {
exit(1); // or handle error somehow
};
Or like this:
if (! $worker->addServer($host, $port)) {
exit(1); // or handle error somehow
};
That said, if some exception were to be thrown, the PHP extension registers the class GearmanException
for doing so. See https://github.com/php/pecl-networking-gearman/blob/69d6b78374fc9914906ecaea0fe919b6903cd526/php_gearman.c#L123
It returns true or false but apparently on some PHP versions (between 7 and 8, I think) if you don't put it in a try catch block, php dies with a fatal error about an uncaught exception, however, putting it in a try catch block, the catch blocking doesn't catch anything, but the fact that it is in a 'try' prevents PHP from dying with an error.
Hello,
In the previous repository, there was an issue around
addServer
making connections for\GearmanClient
which was resolved with a new 3rd parameter. (See https://github.com/wcgallego/pecl-gearman/issues/59)Is there any plan to also support this for
addServer()
andaddServers()
for the\GearmanWorker
class as well? I was able to migrate my code to use the 3rd parameter for\GearmanClient
and avoided theGearmanException: Failed to set exception option
for that case.However, for
\GearmanWorker
I'm still getting an error.And trying to add the 3rd parameter (set to false), I am getting:
gearman extension version => 2.1.0 libgearman version => 1.1.19.1
Thanks for any input!