8000 [Process] timeout not triggered when using process as iterator · Issue #20594 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Process] timeout not triggered when using process as iterator #20594

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

Closed
twifty opened this issue Nov 22, 2016 · 2 comments
Closed

[Process] timeout not triggered when using process as iterator #20594

twifty opened this issue Nov 22, 2016 · 2 comments

Comments

@twifty
Copy link
twifty commented Nov 22, 2016

As the title says, When using Process::getIterator execution hangs regardless of the timeout value. This doesn't happen when using a callback supplied to Process::wait.

Shouldn't the getIterator method internally call checkTimeout?

A workaround is to call getIterator with the ITER_NON_BLOCKING flag, and manually call checkTimeout.

foreach ($process->getIterator(Process::ITER_NON_BLOCKING) as $type => $data) {
    try {
        $process->checkTimeout();
    } catch (\Exception $err) {
        break;
    }
    if (empty($data)) {
        usleep(100);
        continue;
    }
    // Handle data as usual
}
@chalasr
Copy link
Member
chalasr commented Nov 22, 2016

Status: reviewed 👍

See #20600

@twifty
Copy link
Author
twifty commented Nov 23, 2016

Wow, That was a quick fix

fabpot added a commit that referenced this issue Nov 24, 2016
…ng getIterator() (chalasr)

This PR was merged into the 3.1 branch.

Discussion
----------

[Process] Fix process continuing after reached timeout using getIterator()

| Q             | A
| ------------- | ---
| Branch?       | 3.1
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #20594
| License       | MIT
| Doc PR        | n/a

Commits
-------

10992cd [Process] Fix kill process on reached timeout using getIterator()
@fabpot fabpot closed this as completed Nov 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
0