Google-cloud-php: [StorageClient] downloadAsStreamAsync() not being async

Created on 11 May 2020  路  4Comments  路  Source: googleapis/google-cloud-php

I was quite happy that StorageClient in PHP is supporting Async fetch.
But when implementing the method does not seem to be fetching data async but synchron instead.

$StorageClient = new StorageClient(array('transport' => 'grpc'));
$StorageBucket = $StorageClient->bucket('xxx');
$_search_prefix = 'some/prefix/test_';
$_promises = array();
foreach ($StorageBucket->objects(array('prefix' => $_search_prefix)) as $_object) {
    $_promises[] = $_object->downloadAsStreamAsync()->then(function(StreamInterface $data) {
                $_contents = trim($data->getContents());
            });
}
Promise\unwrap($_promises);

Basically as it seem the 2nd downloadAsStreamAsync() is waiting for the first one do finish, but not all downloadAsStreamAsync() are executed async

storage question

All 4 comments

@jdpedrie could you take a look at this issue? Not sure if it's a question or a bug.

@fschirl, the Storage client does not utilize gRPC as a transport option - so that configuration won't have the expected effect. What the client will be falling back on is utilizing Guzzle over HTTP/1.1. The async methods exposed by guzzle required cURL, do you know if your system has it enabled?

Hi @dwsupplee ,
gRPC was already taken out after first test.
php7.3-curl was not installed so far. After adding this module it seems to work.
Many thanks for your support!

@dwsupplee installing php curl library fixed it. now async is working 100% correct. thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dwsupplee picture dwsupplee  路  7Comments

ammopt picture ammopt  路  6Comments

highstrike picture highstrike  路  5Comments

castaneai picture castaneai  路  7Comments

matthewgoslett picture matthewgoslett  路  4Comments