Skip to content

Commit ec29956

Browse files
committed
up fix
1 parent d050332 commit ec29956

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/Consumer.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,26 @@ function pop(float $timeout = 3.0):?Job
2121
return $this->driver->pop($timeout);
2222
}
2323

24-
function listen(callable $call, float $breakTime = 0.01,float $waitTime = 3.0, int $maxCurrency=128)
24+
function listen(callable $call, float $breakTime = 0.01,float $waitTime = 0.1, int $maxCurrency=128)
2525
{
2626
$this->enableListen = true;
2727
$running = 0;
2828
while ($this->enableListen){
2929
if ($running >= $maxCurrency) {
30+
Coroutine::sleep($breakTime);
3031
continue;
3132
}
3233
$job = $this->driver->pop($waitTime);
3334
if($job){
3435
++$running;
3536
Coroutine::create(function () use(&$running, $call, $job){
36-
call_user_func($call,$job);
37-
--$running;
37+
try{
38+
call_user_func($call,$job);
39+
}catch (\Throwable $throwable){
40+
throw $throwable;
41+
}finally{
42+
--$running;
43+
}
3844
});
3945
}else{
4046
Coroutine::sleep($breakTime);

0 commit comments

Comments
 (0)