在退出迭代之前向 guzzle 请求池添加更多请求
add more requests to the guzzle request pool before it exits the iteration
有没有办法在 guzzle 7 退出循环之前将另一个异步请求(可能是在另一个请求的承诺完成后)添加到 guzzle 7 请求队列?
https://docs.guzzlephp.org/en/stable/quickstart.html#async-requests
protected function download(string $url)
{
$fulfilled = function (\GuzzleHttp\Psr7\Response $response) {
// response is ready
(string)$response->getBody();
if('some other url ?'){
$this->download('https:...........');
}
};
$this->iterator->append($this->client->getAsync($url)->then($fulfilled));
}
private function work()
{
$this->client = new \GuzzleHttp\Client();
$this->iterator = new \ArrayIterator();
$this->download('https:...........');
$a = \GuzzleHttp\Promise\Utils::unwrap($this->iterator);
}
有没有办法在 guzzle 7 退出循环之前将另一个异步请求(可能是在另一个请求的承诺完成后)添加到 guzzle 7 请求队列?
https://docs.guzzlephp.org/en/stable/quickstart.html#async-requests
protected function download(string $url)
{
$fulfilled = function (\GuzzleHttp\Psr7\Response $response) {
// response is ready
(string)$response->getBody();
if('some other url ?'){
$this->download('https:...........');
}
};
$this->iterator->append($this->client->getAsync($url)->then($fulfilled));
}
private function work()
{
$this->client = new \GuzzleHttp\Client();
$this->iterator = new \ArrayIterator();
$this->download('https:...........');
$a = \GuzzleHttp\Promise\Utils::unwrap($this->iterator);
}