1
0
Fork 0

Merge remote-tracking branch 'naderman/curl-download-performance-select-not-sleep'

pull/9618/head
Jordi Boggiano 2021-01-17 12:50:53 +01:00
commit 7ea17d7db9
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
2 changed files with 10 additions and 9 deletions

View File

@ -336,13 +336,9 @@ class HttpDownloader
*/ */
public function wait($index = null) public function wait($index = null)
{ {
while (true) { do {
if (!$this->countActiveJobs($index)) { $jobCount = $this->countActiveJobs($index);
return; } while ($jobCount);
}
usleep(1000);
}
} }
/** /**

View File

@ -85,6 +85,7 @@ class Loop
$progress->start($totalJobs); $progress->start($totalJobs);
} }
$lastUpdate = 0;
while (true) { while (true) {
$activeJobs = 0; $activeJobs = 0;
@ -95,15 +96,19 @@ class Loop
$activeJobs += $this->processExecutor->countActiveJobs(); $activeJobs += $this->processExecutor->countActiveJobs();
} }
if ($progress) { if ($progress && microtime(true) - $lastUpdate > 0.1) {
$lastUpdate = microtime(true);
$progress->setProgress($progress->getMaxSteps() - $activeJobs); $progress->setProgress($progress->getMaxSteps() - $activeJobs);
} }
if (!$activeJobs) { if (!$activeJobs) {
break; break;
} }
}
usleep(5000); // as we skip progress updates if they are too quick, make sure we do one last one here at 100%
if ($progress) {
$progress->setProgress($progress->getMaxSteps());
} }
unset($this->currentPromises[$waitIndex]); unset($this->currentPromises[$waitIndex]);