src/Model/Activity.php
public function wait(callable $onPoll = null, callable $onLog = null, $pollInterval = 1)
    {
        $log = $this->getProperty('log');
        if ($onLog !== null && strlen(trim($log))) {
            $onLog(trim($log) . "\n");
        }
        $length = strlen($log);
        $retries = 0;
        while (!$this->isComplete()) {
            usleep($pollInterval * 1000000);
            try {
                $this->refresh(['timeout' => $pollInterval + 5]);
                if ($onPoll !== null) {
                    $onPoll($this);
                }
                if ($onLog !== null && ($new = substr($this->getProperty('log'), $length))) {
                    $onLog(trim($new) . "\n");
                    $length += strlen($new);
                }
            } catch (ConnectException $e) {
                // Retry on timeout.
                if (strpos($e->getMessage(), 'cURL error 28') !== false && $retries <= 5) {
                    $retries++;
                    continue;
                }
                throw $e;
            }
        }
    }
public function wait(callable $onPoll = null, callable $onLog = null, $pollInterval = 1)
    {
        $log = $this->getProperty('log');
        if ($onLog !== null && strlen(trim($log))) {
            $onLog(trim($log) . "\n");
        }
        $length = strlen($log);
        $retries = 0;
        while (!$this->isComplete()) {
            usleep($pollInterval * 1000000);
            try {
                $this->refresh(['timeout' => $pollInterval + 5]);
                if ($onPoll !== null) {
                    $onPoll($this);
                }
                if ($onLog !== null && ($new = substr($this->getProperty('log'), $length))) {
                    $onLog(trim($new) . "\n");
                    $length += strlen($new);
                }
            } catch (ConnectException $e) {
                // Retry on timeout.
                if (strpos($e->getMessage(), 'cURL error 28') !== false && $retries <= 5) {
                    $retries++;
                    continue;
                }
                throw $e;
            }
        }
    }
public function wait ( callable $ onPoll = null , callable $ onLog = null , $ pollInterval = 1 ) { $ log = $ this -> getProperty ( 'log' ) ; if ( $ onLog !== null && strlen ( trim ( $ log ) ) ) { $ onLog ( trim ( $ log ) . "\n" ) ; } $ length = strlen ( $ log ) ; $ retries = 0 ; while ( ! $ this -> isComplete ( ) ) { usleep ( $ pollInterval * 1000000 ) ; try { $ this -> refresh ( [ 'timeout' => $ pollInterval + 5 ] ) ; if ( $ onPoll !== null ) { $ onPoll ( $ this ) ; } if ( $ onLog !== null && ( $ new = substr ( $ this -> getProperty ( 'log' ) , $ length ) ) ) { $ onLog ( trim ( $ new ) . "\n" ) ; $ length += strlen ( $ new ) ; } } catch ( ConnectException $ e ) { // Retry on timeout. if ( strpos ( $ e -> getMessage ( ) , 'cURL error 28' ) !== false && $ retries <= 5 ) { $ retries ++ ; continue ; } throw $ e ; } } }
Wait for the activity to complete.

@todo use the FutureInterface

@param callable  $onPoll       A function that will be called every time
the activity is polled for updates. It
will be passed one argument: the
Activity object.
@param callable  $onLog        A function that will print new activity log
messages as they are received. It will be
passed one argument: the message as a
string.
@param int|float $pollInterval The polling interval, in seconds.
Wait for the activity to complete .