swlib / saber

⚔️ Saber, PHP异步协程HTTP客户端 | PHP Coroutine HTTP client - Swoole Humanization Library
https://packagist.org/packages/swlib/saber
Apache License 2.0
979 stars 124 forks source link

SaberGM::requests -> You can't enqueue a waiting request when using the max concurrency control #27

Open bear-shen opened 5 years ago

bear-shen commented 5 years ago
require __DIR__ . '/../vendor/autoload.php';
go(function () {
    $tidList = [
        '4824528997',
        '5309603784',
        '6042765344',
    ];
    foreach ($tidList as $tid) {
        $requests[] = [
            'uri' => 'https://tieba.baidu.com/p/' . $tid . '?fid=52',
        ];
    }
    $res = \Swlib\SaberGM::requests($requests, [
        'max_co' => 3,
    ]);
});

RT……最小化代码……

报错是这个: RequestQueue.php#L28 Stack trace:

#0 /mnt/hgfs/144/wwwroot/dev_resources/vendor/swlib/saber/src/RequestQueue.php(118): Swlib\Saber\RequestQueue->enqueue(Object(Swlib\Saber\Request))
#1 /mnt/hgfs/144/wwwroot/dev_resources/vendor/swlib/saber/src/Saber.php(278): Swlib\Saber\RequestQueue->recv()
#2 /mnt/hgfs/144/wwwroot/dev_resources/vendor/swlib/saber/src/SaberGM.php(90): Swlib\Saber->requests(Array, Array)
#3 /mnt/hgfs/144/wwwroot/dev_resources/php/zzz_swooleCurl.php(23): Swlib\SaberGM::requests(Array, Array)
#4 {main}
  thrown in /mnt/hgfs/144/wwwroot/dev_resources/vendor/swlib/saber/src/RequestQueue.php on line 28

如果 $tidList 只有两个, max_co 参数无论如何设定都不会产生错误 如果 $tidList 有三个,而且 max_co 大于等于3,就会产生这个报错……

目前还没有仔细去查怎么解决这个问题……不过这个似乎……可以算个bug吧………………

环境 ubuntu 16.04 php 7.1.7 swoole 4.2.13 swlib/saber v1.0.6

goddanao commented 4 years ago

Any update on this?