parallel: How to launch multiple blocking processes
Terribly sorry for making an issue, but I’ve been stuck for a while.
I’m in the need to launch multiple blocking php scripts in a concurrent fashion. Its the same script 20 x times.
I’ve looked at https://github.com/amphp/parallel/blob/master/examples/process.php
and its child:
https://github.com/amphp/parallel/blob/master/examples/blocking-process.php
But I’m struggling to make it launch 20 children ( with different data )
I’ve got something like this:
$promises = [];
for($x = 0; $x <= 10; $x++)
{
$process = new Process(__DIR__ . "/amp-runner.php");
$process->start();
$promises[] = $process->send(x);
}
$all_replies = Promise\wait(Promise\all($promises));
var_dump($all_replies);
But I can’t get it to work.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 68 (27 by maintainers)
Commits related to this issue
- Add interval between starting each worker Experiment for #112. — committed to amphp/parallel by trowski 4 years ago
- Try deferring timeout Relates to #112. — committed to amphp/parallel by kelunik 4 years ago
- Retry IPC connects for 5 seconds Relates to #112. — committed to amphp/parallel by kelunik 4 years ago
- Improve ProcessHub accept watcher Relates to #112. — committed to amphp/parallel by kelunik 4 years ago
@iNilo check this out: https://github.com/JanMikes/php-async-playground i think it is exactly what you are looking for 😃
Not at the moment, no, will try something later.
Ok. Tomorrow. I need to sleep now.