diff --git a/src/AsyncRequest/AsyncRequest.php b/src/AsyncRequest/AsyncRequest.php index e8e8c8a..8465640 100644 --- a/src/AsyncRequest/AsyncRequest.php +++ b/src/AsyncRequest/AsyncRequest.php @@ -87,7 +87,13 @@ public function waitForData(float $timeout = 1.0): void } while (curl_multi_exec($this->handle, $runningCount) === CURLM_CALL_MULTI_PERFORM); - curl_multi_select($this->handle, $timeout); + if($runningCount > 0){ + // still unfinished handles + if(curl_multi_select($this->handle, $timeout) > 0) { + // new data available on handles before $timeout, lets fetch it + while (curl_multi_exec($this->handle, $runningCount) === CURLM_CALL_MULTI_PERFORM); + } + } } /**