Here's the thing, I wanted to request the API, but it sometimes took too long, so I set the timeout to 10 seconds and that worked fine for a while. But now I want to know the exact execution time for every request. I'm thinking of asynchronous requests:
$requestPromise = $client->requestAsync($this->getMethod(), $this->getEndpoint(), [
'form_params' => $this->payload,
'http_errors' => false,
])->then(function (Response $response) {
Log::debug("request success:", ["response" => $response->getBody()->getContents()]);
$this->response = $response;
});
$requestPromise->wait();
but the problem is, the main process has to wait for the response, which I don't want to. Is there a way to somehow wait no more than 10 seconds for the response and then release the main process and not to terminate the second process which is making the request itself ?