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

create worker, work and die ) #875

Open
blackcatt opened this issue Feb 1, 2023 · 2 comments
Open

create worker, work and die ) #875

blackcatt opened this issue Feb 1, 2023 · 2 comments

Comments

@blackcatt
Copy link

Hi, i need to create worker inside other worker and then correctly stop(destroy) it after it do some job.
something like that:

$small_worker = new Worker();
$small_worker->onWorkerStart = function() use (&$small_worker) {
  echo "I've worked and that's enough.\n";
  //$small_worker->stop(); //does not work (
  //Worker::stop(); //does not work (
  die(); // work, but i'm not sure if it's right
}

Thanks

@walkor
Copy link
Owner

walkor commented Feb 2, 2023

Using die() will generate a log. Use Worker::stopAll() instead of die().

@blackcatt
Copy link
Author

Walkor, I used this code ( Worker::stopAll(); ) and it seemed to me that everything works fine. But it's not.
stopAll() will stop mу small_worker AND parent worker too.
But as i wrote i need start small_worker, do some job asynchronously from parent in onWorkerStart and end it without stoppping parent worker.

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

No branches or pull requests

2 participants