1 回答

TA貢獻(xiàn)1936條經(jīng)驗(yàn) 獲得超7個贊
我以這種方式解決這個問題:
$requests = function ($total) {
$uri = 'http://127.0.0.1:8126/guzzle-server/perf';
for ($i = 0; $i < $total; $i++) {
$myAdditionalId = $i;
$promise = $client->getAsync($uri);
$promise->then(function () use ($myAdditionalId){
//add callback with function on success
echo $myAdditionalId;
});
yield function()use($promise){return $promise;};
}
};
$pool = new Pool($client, $requests(100), [
'concurrency' => 5,
'rejected' => function (RequestException $reason, $index) {
// this is delivered each failed request
},
]);
- 1 回答
- 0 關(guān)注
- 93 瀏覽
添加回答
舉報(bào)