Skip to content
New issue

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

Requests are not async actually #32

Open
sevka opened this issue Dec 17, 2024 · 1 comment
Open

Requests are not async actually #32

sevka opened this issue Dec 17, 2024 · 1 comment
Assignees
Labels
type:bug A broken experience

Comments

@sevka
Copy link

sevka commented Dec 17, 2024

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.

@Ndiritu
Copy link
Contributor

Ndiritu commented Dec 17, 2024

Thanks for catching this @sevka. Will look into it asap.

@Ndiritu Ndiritu transferred this issue from microsoft/kiota-http-guzzle-php Feb 10, 2025
@Ndiritu Ndiritu added the type:bug A broken experience label Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug A broken experience
Projects
Status: New📃
Development

No branches or pull requests

2 participants