Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

catch workerException #6

Open
RubtsovAV opened this issue Oct 29, 2016 · 3 comments
Open

catch workerException #6

RubtsovAV opened this issue Oct 29, 2016 · 3 comments
Assignees

Comments

@RubtsovAV
Copy link
Contributor

RubtsovAV commented Oct 29, 2016

Will be good if we can catch of the worker exceptions. For example:

$wp = new WorkerPool();
$wp->onWorkerException(function(\Exception $ex, Worker $worker) {
   // there we can handle the exception (logging, restart the task or other)
});
@qxsch qxsch self-assigned this Mar 26, 2017
@qxsch qxsch closed this as completed Mar 26, 2017
@qxsch qxsch reopened this Mar 26, 2017
@eazrael
Copy link

eazrael commented Nov 9, 2019

The fun part is that you need to serialize exceptions in order to send them via the pipe. Just did this myself. Any ressource or object anywhere either directly as a function parameter or in some nested array/object hierarchy will make the serialization fail. so you will have to iterate recursively through the stack and the objects to remove any non-serializable data. And as objects are references only you will modify the state of your worker. Really funny is PDO which implements __sleep() and just throws an error.

@qxsch
Copy link
Owner

qxsch commented Nov 9, 2019

You get already the stacktrace as string as well as the message as return result.
We avoid serializing the whole stack by serializing the string stack trace only.

@qxsch
Copy link
Owner

qxsch commented Nov 9, 2019

Leaving this ticket open.
Until anyone comes with a good serialization logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants