Skip to content

Requests are not async actually #32

@sevka

Description

@sevka

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.

Metadata

Metadata

Assignees

Labels

type:bugA broken experience

Type

Projects

Status

New📃

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions