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
WIP: ChildProcess #61
WIP: ChildProcess #61
Conversation
require __DIR__.'/../vendor/autoload.php'; | ||
|
||
$loop = new React\EventLoop\StreamSelectLoop(); | ||
$factory = new React\ChildProcess\factory($loop); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Class name should be uppercase Factory
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
|
||
$cmd = $this->createCommand($file, $args); | ||
$cwd = $options && $options['cwd'] ? $options['cwd'] : getcwd(); | ||
$env = $options && $options['env'] ? $options['env'] : $_ENV; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implicitly passing the ENV superglobal is a bad idea imo, as it could contain sensitive information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced $_ENV
with NULL
.
Then the child's $_ENV seems to be empty array.
https://gist.github.com/3386850
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, perfect!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And replaced getcwd()
with NULL
by same reason.
https://gist.github.com/3386926
Very cool, I like this a lot! Regarding the empty string issue, I wasn't aware that is also occurs when not in the socket context. Please adjust the stream class to not emit empty strings (and add a test case for it). Tests for this stuff would be delicious. :) |
Thank you for reviewing! I'll send patch for empty string issue as another Pull Request. And I'll begin writing unit-tests if current API is acceptable. |
|
||
public function spawn($file, $args = NULL, $options = NULL) | ||
{ | ||
$args = $args ? $args : array(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be done in the function declaration:
spawn($file, array $args = array(), array $options = null)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
And all of the NULL
was replaced with null
.
What's the status on this PR? |
This PR would be very useful for my use-case. how can i help get this merged? |
Still waiting for a status update from @yuya-takeyama. Especially regarding the failing tests. I would like to see this in core as well. ;-) |
I'll PIN him. maybe he missed github's new notification. :) |
Nice feature! I hope it will be merged soon for further development and improvements. |
$this->assertNull($capturedExitCodeOfExit); | ||
$this->assertNull($capturedExitCodeOfClose); | ||
$this->assertSame(self::SIGNAL_CODE_SIGTERM, $capturedSignalCodeOfExit); | ||
$this->assertSame(self:: SIGNAL_CODE_SIGTERM, $capturedSignalCodeOfClose); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra space after ::
?
Would it be possible to have a small overview of what's not working yet in this PR ? So far I only see one failing test and I think I know why does it fail, but I'm wondering if there are features that haven't been implemented yet or do not have matching tests. |
Closing in favour of #158. |
This is just a proposal.
And no unit-test code is available now.
Please give me advices for...
Process
beStream
object orresource
variable?Factory
?Executor
?Below is the result of example code
Currently, empty string is emitted when a process is exiting.
It seems because of implementation difference of
Stream->handleData()
andConnection->handleData()
.https://github.com/react-php/react/blob/2a43233661bd148c3eaa9214a89558669d202828/src/React/Socket/Connection.php#L14
https://github.com/react-php/react/blob/2a43233661bd148c3eaa9214a89558669d202828/src/React/Stream/Stream.php#L114
Connection->handleData()
closes when hendled empty string and not emitsdata
event then.But
Stream->handleData()
emits empty string.What is the difference for?