public function wait()
{
while (!$this->isFinished()) {
$this->fetch();
sleep(3);
/**
* TODO: Output this to stdout so that it doesn't get mixed with any
* actual output. We can't use the logger here because that might be
* redirected to a log file where each line is timestamped.
*/
fwrite(STDERR, '.');
}
echo "\n";
if ($this->isSuccessful()) {
return $this;
} else {
$final_task = $this->get('final_task');
if ($final_task != null && !empty($final_task->messages)) {
foreach ($final_task->messages as $data => $message) {
if (!is_string($message->message)) {
$message->message = print_r($message->message, true);
}
throw new TerminusException((string) $message->message);
}
}
}
}