php / pecl-networking-gearman

PHP wrapper to libgearman
https://pecl.php.net/package/gearman
Other
33 stars 25 forks source link

When will GearmanWorker::work be false? #13

Open ifohancroft opened 2 years ago

ifohancroft commented 2 years ago

I have looked everywhere (even tried reading the C source but that didn't help) but I can't find the answer to that.

When will GearmanWorker::work be false? What can/will cause it to "fail" basically? The PHP manual over at php.net says:

Waits for a job to be assigned and then calls the appropriate callback function. Issues an E_WARNING with the last Gearman error if the return code is not one of GEARMAN_SUCCESS, GEARMAN_IO_WAIT, or GEARMAN_WORK_FAIL.

If the return code of what is not one of GEARMAN_SUCCESS, GEARMAN_IO_WAIT or GEARMAN_WORK_FAIL?

Is there a way to see the Gearman Worker class as a PHP code? I.e. as if it was a class written in PHP?

oleg-st commented 2 years ago

Here is the source code for this method: https://github.com/php/pecl-networking-gearman/blob/7da13e4babc17067b2b45d6b37041c3c8ed91637/php_gearman_worker.c#L627

It will return false if return code is not GEARMAN_SUCCESS.

ifohancroft commented 2 years ago

Here is the source code for this method:

https://github.com/php/pecl-networking-gearman/blob/7da13e4babc17067b2b45d6b37041c3c8ed91637/php_gearman_worker.c#L627

It will return false if return code is not GEARMAN_SUCCESS.

Thank you! The return code of what though?

esabol commented 2 years ago

The return code of what though?

The C function gearman_worker_work in libgearman.

See https://github.com/gearman/gearmand/blob/302f33cebf730a9f7356ccdcc4cb8b4c171bd68a/docs/source/libgearman/gearman_return_t.rst for a list of possible errors.

ifohancroft commented 2 years ago

The return code of what though?

The C function gearman_worker_work in libgearman.

I get that, but I am asking on a higher level. What has to happen for $worker->work to return false/what controls what GEARMAN_STATUS would $worker->returnCode() return and in what cases it won't be GEARMAN_SUCCESS?