因此,我正在尝试将guzzle用于几个并发请求。我在网上看到了几个示例,这是我想出的,但似乎无法使其正常工作。没有错误,没有警告,什么都没有。我已经尝试在每个诺言中登录,但没有任何反应。而且我肯定知道什么都不会发生,因为什么都没有插入数据库中。有什么想法我想念的吗?(我产生每个请求及其各自的请求,then因为在每个承诺结束时,数据库操作特定于该用户)use GuzzleHttp\Promise\EachPromise;use Psr\Http\Message\ResponseInterface;$promises = (function () use($userUrls){ $userUrls->each(function($user) { yield $this->client->requestAsync('GET', $user->pivot->url) ->then(function (ResponseInterface $response) use ($user) { $this->dom->load((string)$response->getBody()); // ... some db stuff that inserts row in table for this // $user with stuff from this request }); });});$all = new EachPromise($promises, [ 'concurrency' => 4, 'fulfilled' => function () { },]);$all->promise()->wait();
1 回答
- 1 回答
- 0 关注
- 124 浏览
添加回答
举报
0/150
提交
取消