parallel icon indicating copy to clipboard operation
parallel copied to clipboard

ContextException: Starting the process failed

Open enumag opened this issue 5 years ago • 10 comments

Lately I'm getting this error when using amphp/parallel. When I check the previous exception it is

Amp\Parallel\Context\ContextException: Starting the process timed out.

Any idea what could be wrong here and how to fix it?

enumag avatar Jul 16 '20 08:07 enumag

I tried to wrap the yield enqueue($task); call in a loop, catching the exception and retry on failure. With that I'm getting this:

User Warning: Worker in pool crashed with exception on shutdown: User Warning: Worker in pool exited unexpectedly with code -1

enumag avatar Jul 16 '20 08:07 enumag

I tried with both uv and native driver, same result.

enumag avatar Jul 16 '20 08:07 enumag

The issue disappeared when I removed xdebug. :thinking:

enumag avatar Jul 16 '20 10:07 enumag

It appears that you're starting a worker from within another worker, is that the case?

How many workers total are you spawning?

trowski avatar Jul 16 '20 14:07 trowski

Issue can be solved by modifying Amp\Parallel\Context\Internal\ProcessHub::PROCESS_START_TIMEOUT. It would be cool to have this configurable instead of hardcoded.

EDIT: I'm using grumphp and it's spawning multiple xdebug instances. After increasing said constant the issue went away.

adrianpanicek avatar Jul 30 '20 08:07 adrianpanicek

It appears that you're starting a worker from within another worker, is that the case?

No. Worker was started from the main loop process.

How many workers total are you spawning?

The error appeared with the first worker already.

enumag avatar Jul 30 '20 08:07 enumag

Issue can be solved by modifying Amp\Parallel\Context\Internal\ProcessHub::PROCESS_START_TIMEOUT. It would be cool to have this configurable instead of hardcoded.

EDIT: I'm using grumphp and it's spawning multiple xdebug instances. After increasing said constant the issue went away.

How far did you increase it? I remember trying that as well to no avail.

enumag avatar Jul 30 '20 08:07 enumag

@enumag I just added zero at the end.

adrianpanicek avatar Jul 30 '20 10:07 adrianpanicek

Yeah, I tried even higher to no avail. It's simply not working for me with xdebug active.

enumag avatar Aug 03 '20 13:08 enumag

Hi, I have this problem too. I have no xdebug install, and i try to increase PROCESS_START_TIMEOUT with no success. I just try to execute the code on this link https://amphp.org/parallel/ My environnement : centos 7 apache 2.4.6 php 7.2

the error :

<status>500</status> <error>Amp\Parallel\Context\ContextException</error> <message>Starting the process failed</message> <file>.../vendor/amphp/parallel/lib/Context/Process.php</file> <line>202</line>

<trace> 0 [internal function]: Amp\Parallel\Context\Process->Amp\Parallel\Context{closure}() 1 .../vendor/amphp/amp/lib/Coroutine.php(115): Generator->throw(Object(Amp\Parallel\Context\ContextException)) 2 .../vendor/amphp/amp/lib/Failure.php(33): Amp\Coroutine->Amp{closure}(Object(Amp\Parallel\Context\ContextException), NULL) 3 .../vendor/amphp/amp/lib/Internal/Placeholder.php(143): Amp\Failure->onResolve(Object(Closure)) 4 .../vendor/amphp/amp/lib/Internal/Placeholder.php(177): Amp\Coroutine->resolve(Object(Amp\Failure)) 5 .../vendor/amphp/amp/lib/Coroutine.php(137): Amp\Coroutine->fail(Object(Amp\Parallel\Context\ContextException)) 6 .../vendor/amphp/amp/lib/Failure.php(33): Amp\Coroutine->Amp{closure}(Object(Amp\TimeoutException), NULL) 7 .../vendor/amphp/amp/lib/Internal/Placeholder.php(143): Amp\Failure->onResolve(Object(Closure)) 8 .../vendor/amphp/amp/lib/Internal/Placeholder.php(177): class@anonymous->resolve(Object(Amp\Failure)) 9 .../vendor/amphp/amp/lib/Deferred.php(65): class@anonymous->fail(Object(Amp\TimeoutException)) 10 .../vendor/amphp/amp/lib/functions.php(275): Amp\Deferred->fail(Object(Amp\TimeoutException)) 11 .../vendor/amphp/amp/lib/Loop/NativeDriver.php(111): Amp\Promise{closure}('r', NULL) 12 .../vendor/amphp/amp/lib/Loop/Driver.php(138): Amp\Loop\NativeDriver->dispatch(true) 13 .../vendor/amphp/amp/lib/Loop/Driver.php(72): Amp\Loop\Driver->tick() 14 .../vendor/amphp/amp/lib/Loop.php(95): Amp\Loop\Driver->run() 15 .../vendor/amphp/amp/lib/functions.php(229): Amp\Loop::run(Object(Closure)) 16 .../Controller/Admin.php(65): Amp\Promise\wait(Object(Amp\Internal\PrivatePromise)) 17 [internal function]: Api\Controller\Admin->test() </trace>

Thank for your help

sakuraza avatar Sep 02 '20 07:09 sakuraza

Closing this issue, since this has been completely refactored in v2 to allow full customization of context IPC.

trowski avatar Dec 30 '22 01:12 trowski