Autoloading fail
ebeyrent opened this issue · 1 comments
I'm trying to use parallel in the context of Drupal, which uses composer and autoloading.
When I execute this code:
`$queue_configs = $this->getMessageQueueConfigurations();
$pool = new ContextWorkerPool(count($queue_configs));
$threads = [];
foreach ($queue_configs as $queue_config) {
$task = new MessageQueueProcessorTask(
$this->uniqueQueueFactory,
$queue_config
);
$threads[] = $pool->submit($task);
}
$responses = Future\await(array_map(
fn(Worker\Execution $execution) => $execution->getFuture(),
$threads
));`
I get `Amp\Parallel\Worker\TaskFailureError: Error thrown in context with message "Classes implementing Amp\Parallel\Worker\Task must be autoloadable by the Composer autoloader" and code "0"`
I'm not sure how to deal with this - I've added a require to autoload.php within my MessageQueueProcessorTask class, but that didn't work.
I found the solution in another thread - it was a matter or adding a new entry to composer.json in the autoload/psr-4 section to load my tasks outside the Drupal module namespace.