I am trying to use Amphp Parallel functions with the Magento framework in a custom module.
try {
$response = wait(parallelMap($items, function ($item) use ($arg1){
$this->getCustomItems( $item, $arg1);
}));
} catch (MultiReasonException $exception) {
foreach ($exception->getReasons() as $reason) {
var_dump($reason->getMessage());
}
}
The issue i am having when running the above code is
Uncaught RuntimeException in worker with message "ObjectManager isn't initialized" and code "0"; use Amp\Parallel\Worker\TaskFailureException::getOriginalTrace() for the stack trace in the worker
The Magento framework is autoloaded using composer. So i have no clue as to why it can not initialize the object manager.
Magento's dependencies are autoloaded with the autoload, but it is of no use when it is not initialized by the Magento kernel, you need to create a separate Magento API, and request that API by call back method (using CURL request) written in your vendor/autloload.php, this is how you can make use of amphp.