How to wait for guzzle request to be completed while doing something else during waiting?
<p>I want to do something in a loop while a guzzle request is going on and then just continue the script when the request ends, for example I want to do something like this :</p>

<pre><code>$client = new \GuzzleHttp\Client();
$promise = $client-&gt;headAsync("https://www.google.com");
$promise-&gt;then(
  function (ResponseInterface $res) {
    echo $res-&gt;getStatusCode() . "\n";
  },
  function (RequestException $e) {
    echo $e-&gt;getMessage() . "\n";
  }
);
while($promise-&gt;getState() === "pending"){
  $queue = \GuzzleHttp\Promise\queue();
  $queue-&gt;run();
  echo "Waiting\n";
  sleep(1);
}
</code></pre>

<p>and this code just prints "Waiting" for ever. how can I achieve this ?</p>