mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-09-15 12:56:40 +00:00
Fix flaky rate limit tests caused by inconsistent sleep times
This commit is contained in:
@@ -1165,7 +1165,15 @@ class MultiCurl
|
||||
// Avoid using time_sleep_until() as it appears to be less precise and not sleep long enough.
|
||||
usleep($sleep_seconds * 1000000);
|
||||
|
||||
// Ensure that enough time has passed as usleep() may not have waited long enough.
|
||||
$this->currentStartTime = microtime(true);
|
||||
if ($this->currentStartTime < $sleep_until) {
|
||||
do {
|
||||
usleep(1000000 / 4);
|
||||
$this->currentStartTime = microtime(true);
|
||||
} while ($this->currentStartTime < $sleep_until);
|
||||
}
|
||||
|
||||
$this->currentRequestCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user