-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Process] Adds usleep(1000) to ease CPU usage. #28940
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
Conversation
miniyarov
commented
Oct 21, 2018
Q | A |
---|---|
Branch? | master |
Bug fix? | yes |
New feature? | no |
BC breaks? | no |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | |
License | MIT |
Doc PR | symfony/symfony-docs |
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.
Break if process is not running in waitUntil
@nicolas-grekas added a break if process is not running |
@@ -465,6 +465,11 @@ public function waitUntil(callable $callback) | |||
$this->fallbackStatus['exitcode'] = (int) $data; | |||
} | |||
} | |||
if ($this->isRunning()) { |
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.
what about writting in this way:
if ($wait && !$this->isRunning()) {
return false;
}
and make the function return a boolean (type-hint+return true at the end)
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.
Hmm this might change function's specification but doable
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.
The method is new so we can still do it. It'd make sense to me.
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.
Ok updated to return a boolean.
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.
(with one last comment, thanks!)
@@ -437,11 +437,13 @@ public function wait(callable $callback = null) | |||
* It allows to have feedback from the independent process during execution. | |||
* | |||
* @param callable $callback | |||
* | |||
* @return bool |
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.
should be removed (same for $callback btw) as we remove docblocks that don't add anything on top of the PHP signature.
@nicolas-grekas Thanks to you too! |
f23d687
to
9d1416a
Compare
Thank you @miniyarov. |
This PR was squashed before being merged into the 4.2-dev branch (closes #28940). Discussion ---------- [Process] Adds usleep(1000) to ease CPU usage. | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | symfony/symfony-docs Commits ------- 9d1416a [Process] Adds usleep(1000) to ease CPU usage.
Could we have tests for this boolean return value ? |
The while condition was the opposite of the previous while. This was obviously leading to the death of this loop. Loop which was useful according to some people (see symfony#28940), so I just moved the code to the right position.