我正在尝试在自定义模块中将 Amphp Parallel 函数与 Magento 框架一起使用。
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());
}
}
运行上述代码时我遇到的问题是
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
Magento 框架是使用 composer 自动加载的。所以我不知道为什么它不能初始化对象管理器。