microsoft / microsoft/kiota-php

Requests are not async actually

Open
#32 1 comment 0 reactions 1 assignee View on GitHub

@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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.