Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Process cannot be started exception #12

Closed
PeeHaa opened this issue Nov 8, 2018 · 7 comments
Closed

Process cannot be started exception #12

PeeHaa opened this issue Nov 8, 2018 · 7 comments

Comments

@PeeHaa
Copy link

PeeHaa commented Nov 8, 2018

I suspect this is actually rather an amp/process issue instead, but this is where I found it.

OS: Windows
PHP version: PHP 7.2.2 (cli) (built: Jan 31 2018 19:31:17) ( ZTS MSVC15 (Visual C++ 2017) x64 )
Driver: native
Package versions:

amphp/amp v2.0.7
amphp/byte-stream v1.5.0
amphp/parallel v1.0.1
amphp/parallel-functions v0.1.3
amphp/parser v1.0.0
amphp/process v1.0.0
amphp/sync v1.0.1

Repro:

\Amp\Loop::run(function() {
    yield \Amp\ParallelFunctions\parallel(function() {
        return password_verify('foo', 'bar');
    })();
});

Error:

$ php example/test.php

PHP Fatal error: Uncaught Amp\Process\StatusError: Process has not been started or has not completed starting. in D:\Web\HarmonyIO\Validation\vendor\amphp\process\lib\Process.php:239
Stack trace:
#0 D:\Web\HarmonyIO\Validation\vendor\amphp\parallel\lib\Context\Process.php(190): Amp\Process\Process->getStdin()
#1 [internal function]: Amp\Parallel\Context\Process->Amp\Parallel\Context{closure}()
#2 D:\Web\HarmonyIO\Validation\vendor\amphp\amp\lib\Coroutine.php(74): Generator->send(3992)
#3 D:\Web\HarmonyIO\Validation\vendor\amphp\amp\lib\Internal\Placeholder.php(127): Amp\Coroutine->Amp{closure}(NULL, 3992)
#4 D:\Web\HarmonyIO\Validation\vendor\amphp\amp\lib\Coroutine.php(79): Amp\Coroutine->resolve(3992)
#5 D:\Web\HarmonyIO\Validation\vendor\amphp\amp\lib\Internal\Placeholder.php(127): Amp\Coroutine->Amp{closure}(NULL, 3992)
#6 D:\Web\HarmonyIO\Validation\vendor\amphp\amp\lib\Deferred.php(41): class@anonymous->resolve(3992)
#7 D:\Web\HarmonyIO\Validation\vendor\amphp\process\lib\Internal\Windows\SocketConnector.php(260): Am in D:\Web\HarmonyIO\Validation\vendor\amphp\parallel\lib\Context\Process.php on line 195

@trowski
Copy link
Member

trowski commented Nov 8, 2018

Can you test with master of amphp/process?

@PeeHaa
Copy link
Author

PeeHaa commented Nov 8, 2018

Yes! \o/

With master of process it works. But it hangs after execution:

var_dump('START SCRIPT');

\Amp\Loop::run(function() {
    var_dump('ENTERED LOOP');
    $promise = \Amp\ParallelFunctions\parallel(function () {
        var_dump('ENTERED PARALLEL FUNCTION');

        return password_verify('1234567890', '$2y$10$PcRLWTmmlKptOuNnAZfmneSKIL7sSZ.j2ELZuNSncVSzqoovWNVzC');
    })();

    var_dump('CONTINUING LOOP');

    $result = yield $promise;

    var_dump('RESOLVED PROMSIE');

    var_dump($result);

    var_dump('EXITING LOOP');
});

var_dump('SCRIPT FINISHED');
$ php test/test.php

string(12) "START SCRIPT"
string(12) "ENTERED LOOP"
string(15) "CONTINUING LOOP"
string(25) "ENTERED PARALLEL FUNCTION"
string(16) "RESOLVED PROMSIE"
bool(true)
string(12) "EXITING LOOP"
string(15) "SCRIPT FINISHED"
script hangs here

@PeeHaa
Copy link
Author

PeeHaa commented Nov 8, 2018

When adding yield \Amp\Parallel\Worker\pool()->shutdown(); to the end of the loop it's working as expected.

@PeeHaa
Copy link
Author

PeeHaa commented Nov 8, 2018

Some more test info.

Running the tests in amphp/process they all work: https://gist.github.com/PeeHaa/3cfe9a667243f2a53138d368bae30ee6

Running the tests in amphp/parallel I get several "PHP Fatal error: Uncaught Amp\Process\StatusError: Process has not been started or has not completed starting." errors: https://gist.github.com/PeeHaa/5597d20bc7795573aec5451b896d6264

PHP Fatal error: Uncaught Amp\Process\StatusError: Process has not been started or has not completed starting. in D:\Web\playground\trowski\parallel\vendor\amphp\process\lib\Process.php:239

@PeeHaa
Copy link
Author

PeeHaa commented Nov 8, 2018

After running the amphp/parallel tests with the fixed process checkout the only thing that fails (hangs) is $ php examples/worker-pool-simple.php: https://gist.github.com/PeeHaa/5597d20bc7795573aec5451b896d6264

@PeeHaa
Copy link
Author

PeeHaa commented Nov 8, 2018

Small update after some more debugging.

amphp\process\lib\Internal\Windows\Runner.php:91 starts the process, but there is never a proc_close which kills it again.

@trowski
Copy link
Member

trowski commented Nov 9, 2018

Fixed by removing a call to stream_get_contents that was hanging in the Windows process runner in amphp/process.

@trowski trowski closed this as completed Nov 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants