Skip to content

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

@twifty

Description

@twifty

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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions