microsoft / microsoft/kiota-php
Requests are not async actually
Open
@Ndiritu is already working on this.
Since Dec 17, 2024.
type:bug
- Dominant language
- PHP
- Stars
- 8
- Forks
- 10
- Avg merge
- 10h 16m
- Merged PRs (30d)
- 3
Description
I noticed that requests are not sent asynchronously no matter I call methods like \Microsoft\Kiota\Http\GuzzleRequestAdapter::sendPrimitiveAsync()
It ends up with calling the sync Guzzle send() method:
\GuzzleHttp\Client::send()
Example of the code:
<?php
require 'vendor/autoload.php';
use Microsoft\Kiota\Authentication\Oauth\ClientCredentialContext;
use Microsoft\Graph\GraphServiceClient;
// skip auth
$graphServiceClient = new GraphServiceClient($tokenRequestContext);
$files = [
'XXX' => 'XXX.jpg', // IDs are changed
'YYY' => 'YYY.jpg',
'ZZZ' => 'ZZZ.jpg',
];
foreach ($files as $fileId => $fileName) {
print("Downloading file $fileName\n");
$promise = $graphServiceClient->drives()
->byDriveId('AAAAAAAAAA')->items()
->byDriveItemId($fileId)->content()->get()->then(
function($fileContent) use ($fileName) {
print("File $fileName downloaded successfully\n");
file_put_contents($fileName, $fileContent);
}
);
}
Every file download is running synchronously, but I expect it running in parallel.
Thanks.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.