Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[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

Merged
merged 1 commit into from
Oct 23, 2018

Conversation

miniyarov
Copy link
Contributor

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

@miniyarov miniyarov changed the title Adds usleep(1000) to ease CPU usage. [Process] Adds usleep(1000) to ease CPU usage. Oct 21, 2018
@nicolas-grekas nicolas-grekas added this to the 4.2 milestone Oct 22, 2018
Copy link
Contributor Author

@miniyarov miniyarov left a 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

@miniyarov
Copy link
Contributor Author

@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()) {
Copy link
Member

@nicolas-grekas nicolas-grekas Oct 22, 2018

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)

Copy link
Contributor Author

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

Copy link
Member

@nicolas-grekas nicolas-grekas Oct 22, 2018

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.

Copy link
Contributor Author

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.

Copy link
Member

@nicolas-grekas nicolas-grekas left a 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
Copy link
Member

@nicolas-grekas nicolas-grekas Oct 22, 2018

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.

@miniyarov
Copy link
Contributor Author

@nicolas-grekas Thanks to you too!

@nicolas-grekas
Copy link
Member

Thank you @miniyarov.

@nicolas-grekas nicolas-grekas merged commit 9d1416a into symfony:master Oct 23, 2018
nicolas-grekas added a commit that referenced this pull request Oct 23, 2018
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.
@stof
Copy link
Member

stof commented Oct 23, 2018

Could we have tests for this boolean return value ?

@nicolas-grekas
Copy link
Member

@stof please check #28958

Nek- added a commit to Nek-/symfony that referenced this pull request Oct 29, 2018
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants