amphp / parallel-functions

Simplified parallel processing for PHP based on Amp.
https://amphp.org/parallel-functions
MIT License
268 stars 18 forks source link

Getting Multiple errors encountered; use Amp\MultiReasonException::getReasons() #32

Open jaydp opened 2 years ago

jaydp commented 2 years ago

When I tried to run following code then it works fine $values = Promise\wait(parallelMapAlias([5,6], function ($string) { return $string * $string; })); print_r($values);

give me output Array ( [0] => 25 [1] => 36 )

But when I add more array to argument then give me following error

Sample Code: (Added 7) $values = Promise\wait(parallelMapAlias([5,6,7], function ($string) { return $string * $string; })); print_r($values);

Error: `PHP Fatal error: Uncaught Amp\MultiReasonException: Multiple errors encountered; use Amp\MultiReasonException::getReasons() to retrieve the array of exceptions thrown in /WebProjects/example/amp/vendor/amphp/parallel-functions/src/functions.php:59 Stack trace:

0 [internal function]: Amp\ParallelFunctions{closure}()

1 /WebProjects/example/amp/vendor/amphp/amp/lib/Coroutine.php(118): Generator->send()

2 /WebProjects/example/amp/vendor/amphp/amp/lib/Internal/Placeholder.php(149): Amp\Coroutine->Amp{closure}()

3 /WebProjects/example/amp/vendor/amphp/amp/lib/Deferred.php(53): class@anonymous->resolve()

4 /WebProjects/example/amp/vendor/amphp/amp/lib/functions.php(546): Amp\Deferred->resolve()

5 /WebProjects/example/amp/vendor/amphp/amp/lib/Internal/ResolutionQueue.php(70): Amp\Promise{closure}()

6 /WebProjects/example/amp/vendor/amphp/amp/lib/Failure.php(33): Amp\Internal\ResolutionQueue->__invoke()

7 /WebProjects/example/amp/vendor/amphp/amp/lib/Internal/Placeholder.php(143): Amp\Failure->onResolve()

8 /WebProjects/ex in /WebProjects/example/amp/vendor/amphp/parallel-functions/src/functions.php on line 59

`

REF From : https://amphp.org/parallel-functions/

kelunik commented 2 years ago

Please follow the instructions in the error message and look at the reasons that cause this.

jaydp commented 2 years ago

I checked that but I can't find detailed error. Let me know, how can I print detailed error. Even, I can't see anything in php error log.

Amp\MultiReasonException::__set_state(array( 'reasons' => array ( 0 => Amp\Parallel\Context\ContextException::__set_state(array( 'message' => 'Starting the process failed', 'string' => '', 'code' => 0, 'file' => '/TestProject/composer/vendor/amphp/parallel/lib/Context/Process.php', 'line' => 202, 'trace' => array ( 0 => array ( 'function' => 'Amp\\Parallel\\Context\\{closure}', 'class' => 'Amp\\Parallel\\Context\\Process', 'type' => '->', ), 1 => array ( 'file' => '/TestProject/composer/vendor/amphp/amp/lib/Coroutine.php', 'line' => 115, 'function' => 'throw', 'class' => 'Generator', 'type' => '->', ), 2 => array ( 'file' => '/TestProject/composer/vendor/amphp/amp/lib/Failure.php', 'line' => 33, 'function' => 'Amp\\{closure}', 'class' => 'Amp\\Coroutine', 'type' => '->', ), 3 => array ( 'file' => '/TestProject/composer/vendor/amphp/amp/lib/Internal/Placeholder.php', 'line' => 143, 'function' => 'onResolve', 'class' => 'Amp\\Failure', 'type' => '->', ), 4 => array ( 'file' => '/TestProject/composer/vendor/amphp/amp/lib/Internal/Placeholder.php', 'line' => 177, 'function' => 'resolve', 'class' => 'Amp\\Coroutine', 'type' => '->', ), 5 => array ( 'file' => '/TestProject/composer/vendor/amphp/amp/lib/Coroutine.php', 'line' => 137, 'function' => 'fail', 'class' => 'Amp\\Coroutine', 'type' => '->', ), 6 => array ( 'file' => '/TestProject/composer/vendor/amphp/amp/lib/Failure.php', 'line' => 33, 'function' => 'Amp\\{closure}', 'class' => 'Amp\\Coroutine', 'type' => '->', ), 7 => array ( 'file' => '/TestProject/composer/vendor/amphp/amp/lib/Internal/Placeholder.php', 'line' => 143, 'function' => 'onResolve', 'class' => 'Amp\\Failure', 'type' => '->', ), 8 => array ( 'file' => '/TestProject/composer/vendor/amphp/amp/lib/Internal/Placeholder.php', 'line' => 177, 'function' => 'resolve', 'class' => 'class@anonymous' . "\0" . '/TestProject/composer/vendor/amphp/amp/lib/Deferred.php:22$53', 'type' => '->', ), 9 => array ( 'file' => '/TestProject/composer/vendor/amphp/amp/lib/Deferred.php', 'line' => 66, 'function' => 'fail', 'class' => 'class@anonymous' . "\0" . '/TestProject/composer/vendor/amphp/amp/lib/Deferred.php:22$53', 'type' => '->', ), 10 => array ( 'file' => '/TestProject/composer/vendor/amphp/amp/lib/functions.php', 'line' => 275, 'function' => 'fail', 'class' => 'Amp\\Deferred', 'type' => '->', ), 11 => array ( 'file' => '/TestProject/composer/vendor/amphp/amp/lib/Loop/NativeDriver.php', 'line' => 142, 'function' => 'Amp\\Promise\\{closure}', ), 12 => array ( 'file' => '/TestProject/composer/vendor/amphp/amp/lib/Loop/Driver.php', 'line' => 138, 'function' => 'dispatch', 'class' => 'Amp\\Loop\\NativeDriver', 'type' => '->', ), 13 => array ( 'file' => '/TestProject/composer/vendor/amphp/amp/lib/Loop/Driver.php', 'line' => 72, 'function' => 'tick', 'class' => 'Amp\\Loop\\Driver', 'type' => '->', ), 14 => array ( 'file' => '/TestProject/composer/vendor/amphp/amp/lib/Loop.php', 'line' => 95, 'function' => 'run', 'class' => 'Amp\\Loop\\Driver', 'type' => '->', ), 15 => array ( 'file' => '/TestProject/composer/vendor/amphp/amp/lib/functions.php', 'line' => 229, 'function' => 'run', 'class' => 'Amp\\Loop', 'type' => '::', ), 16 => array ( 'file' => '/TestProject/application/controllers/test/other.php', 'line' => 4867, 'function' => 'Amp\\Promise\\wait', ), 17 => array ( 'file' => '/TestProject/system/core/CodeIgniter.php', 'line' => 360, 'function' => 'ampParallelFun', 'class' => 'Other', 'type' => '->', ), 18 => array ( 'file' => '/TestProject/public/index.php', 'line' => 145, 'args' => array ( 0 => '/TestProject/system/core/CodeIgniter.php', ), 'function' => 'require_once', ), ), 'previous' => Amp\Parallel\Context\ContextException::__set_state(array( 'message' => 'Starting the process timed out', 'string' => '', 'code' => 0, 'file' => '/TestProject/composer/vendor/amphp/parallel/lib/Context/Internal/ProcessHub.php', 'line' => 141, 'trace' => array ( 0 => array ( 'function' => 'Amp\\Parallel\\Context\\Internal\\{closure}', 'class' => 'Amp\\Parallel\\Context\\Internal\\ProcessHub', 'type' => '->', ), 1 => array ( 'file' => '/TestProject/composer/vendor/amphp/amp/lib/Coroutine.php', 'line' => 115, 'function' => 'throw', 'class' => 'Generator', 'type' => '->', ), 2 => array ( 'file' => '/TestProject/composer/vendor/amphp/amp/lib/Failure.php', 'line' => 33, 'function' => 'Amp\\{closure}', 'class' => 'Amp\\Coroutine', 'type' => '->', ), 3 => array ( 'file' => '/TestProject/composer/vendor/amphp/amp/lib/Internal/Placeholder.php', 'line' => 143, 'function' => 'onResolve', 'class' => 'Amp\\Failure', 'type' => '->', ), 4 => array ( 'file' => '/TestProject/composer/vendor/amphp/amp/lib/Internal/Placeholder.php', 'line' => 177, 'function' => 'resolve', 'class' => 'class@anonymous' . "\0" . '/TestProject/composer/vendor/amphp/amp/lib/Deferred.php:22$53', 'type' => '->', ), 5 => array ( 'file' => '/TestProject/composer/vendor/amphp/amp/lib/Deferred.php', 'line' => 66, 'function' => 'fail', 'class' => 'class@anonymous' . "\0" . '/TestProject/composer/vendor/amphp/amp/lib/Deferred.php:22$53', 'type' => '->', ), 6 => array ( 'file' => '/TestProject/composer/vendor/amphp/amp/lib/functions.php', 'line' => 275, 'function' => 'fail', 'class' => 'Amp\\Deferred', 'type' => '->', ), 7 => array ( 'file' => '/TestProject/composer/vendor/amphp/amp/lib/Loop/NativeDriver.php', 'line' => 142, 'function' => 'Amp\\Promise\\{closure}', ), 8 => array ( 'file' => '/TestProject/composer/vendor/amphp/amp/lib/Loop/Driver.php', 'line' => 138, 'function' => 'dispatch', 'class' => 'Amp\\Loop\\NativeDriver', 'type' => '->', ), 9 => array ( 'file' => '/TestProject/composer/vendor/amphp/amp/lib/Loop/Driver.php', 'line' => 72, 'function' => 'tick', 'class' => 'Amp\\Loop\\Driver', 'type' => '->', ), 10 => array ( 'file' => '/TestProject/composer/vendor/amphp/amp/lib/Loop.php', 'line' => 95, 'function' => 'run', 'class' => 'Amp\\Loop\\Driver', 'type' => '->', ), 11 => array ( 'file' => '/TestProject/composer/vendor/amphp/amp/lib/functions.php', 'line' => 229, 'function' => 'run', 'class' => 'Amp\\Loop', 'type' => '::', ), 12 => array ( 'file' => '/TestProject/application/controllers/test/other.php', 'line' => 4867, 'function' => 'Amp\\Promise\\wait', ), 13 => array ( 'file' => '/TestProject/system/core/CodeIgniter.php', 'line' => 360, 'function' => 'ampParallelFun', 'class' => 'Other', 'type' => '->', ), 14 => array ( 'file' => '/TestProject/public/index.php', 'line' => 145, 'args' => array ( 0 => '/TestProject/system/core/CodeIgniter.php', ), 'function' => 'require_once', ), ),

jaydp commented 2 years ago

it shows Starting the process failed but there is not reason for that.