Skip to content

Commit

Permalink
Merge pull request #131 from aslojno/master
Browse files Browse the repository at this point in the history
Fix: async loop breaks after 20 seconds
  • Loading branch information
isublimity committed Jan 17, 2020
2 parents 5bf3c5e + babfd46 commit 20fa9e4
Showing 1 changed file with 4 additions and 27 deletions.
31 changes: 4 additions & 27 deletions src/Transport/CurlerRolling.php
Expand Up @@ -6,6 +6,8 @@

class CurlerRolling
{
const SLEEP_DELAY = 1000; // 1ms

/**
* @var int
*
Expand Down Expand Up @@ -143,32 +145,10 @@ private function makeResponse($oneHandle)
*/
public function execLoopWait()
{
$c = 0;
$timeStart=time();
$uSleep=1000; // Timer: check response from server, and add new Task/Que to loop
$PendingAllConnections=$this->countPending();

// Max loop check

$count=0;
// add all tasks
do {
$this->exec();
$timeWork=time()-$timeStart;
//
$ActiveNowConnections = $this->countActive();
$PendingNowConnections = $this->countPending();

$count=$ActiveNowConnections+$PendingNowConnections;
$c++;

if ($c > 20000) {
break;
}

usleep($uSleep);
// usleep(2000000) == 2 seconds
} while ($count);
usleep(self::SLEEP_DELAY);
} while (($this->countActive() + $this->countPending()) > 0);

return true;
}
Expand Down Expand Up @@ -339,13 +319,11 @@ public function exec()

public function makePendingRequestsQue()
{

$max = $this->getSimultaneousLimit();
$active = $this->countActive();


if ($active < $max) {

$canAdd = $max - $active;
// $pending = sizeof($this->pendingRequests);

Expand All @@ -372,7 +350,6 @@ public function makePendingRequestsQue()
foreach ($ll as $task_id) {
$this->_prepareLoopQue($task_id);
}

}// if add
}// if can add
}
Expand Down

0 comments on commit 20fa9e4

Please sign in to comment.