We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
$data = []; $promises=[]; Http::concurrency(10)->multiAsync($promises, function (Response $response, $index) use(&$data) { $data[]= $response->body(); }, function (RequestException $e, $index) { echo "发起第 $index 个请求失败,失败原因:" . $e->getMessage() . PHP_EOL; }); print_r($data);
返回空
GuzzleHttp 是没问题的
$requests = function () use ($array) { $uri = ''; foreach ($array as $val) { yield new Request('GET', $uri ); } }; $pool = new Pool( $client, $requests(), [ 'concurrency' => 10, //同时执行 'fulfilled' => function ($response, $index) use (&$data, &$error) { $res = json_decode($response->getBody()->getContents(),1); $data+=$res['data']; }, 'rejected' => function ($reason, $index) { // 失败的响应 $error = $reason; }, ] ); $promise = $pool->promise(); $promise->wait(); print_r($data);
The text was updated successfully, but these errors were encountered:
No branches or pull requests
返回空
GuzzleHttp 是没问题的
The text was updated successfully, but these errors were encountered: