I have the following code:
$client = new Client($conf);
//Pool of requests
$requests = function ($data) use ($client) {
yield function () use ($client, $pixel) {
....
}
}
//Pool of fullfilled
$fullfilled = function ($response, $index) use ($data) {
...
}
//Pool of rejected
$rejected = function ($reason, $index) use ($data) {
...
}
$pool = new Pool($client, $requests($data), [
'concurrency' => 10, 'fulfilled' => $fullfilled, 'rejected' => $rejected
]);
// Initiate the transfers and create a promise
$promise = $pool->promise();
$promise->wait();
I'm not sure I'm using the "wait" properly, but I want the process to be async. Currently, the request hangs and if I omit the wait then the pool will not be sent at all. Ideas?
The Guzzle documentation describes how to make multiple concurrent requests using promises: http://docs.guzzlephp.org/en/latest/quickstart.html#concurrent-requests
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With