Skip to content

Bug: ContainerClient.download_blob works once but not twice in windows  #32458

Open
@PabloRuizCuevas

Description

@PabloRuizCuevas
  • azure.storage.blob.aio:
  • 18.3.1:
  • Windows:
  • 3.11:

Describe the bug

The code aio download_blob of the azure blob works once but not twice when run with asyncio.run, this looks like a bug related to aiohttp, but could not figure out how to solve it. (Windows)

The code i have to reproduce it is almost a copy from their original example at: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/storage/azure-storage-blob/samples/blob_samples_hello_world_async.py

To Reproduce

from azure.storage.blob.aio import ContainerClient
from azure.identity import DefaultAzureCredential
credentials = DefaultAzureCredential()

async def test(conn_client):
    async with conn_client as client_conn:
        stream = await client_conn.download_blob(my_path)
        data = await stream.readall()
    return data

if __name__ == "__main__":
    my_container_name = "Container name"
    my_client = ContainerClient.from_container_url(container_url=my_container_name, credential=credentials)
    my_path = 'test_path'

    data = asyncio.run(test(my_client)) # works and returns the file from blob storage
    data2 = asyncio.run(test(my_client)) # doesn't work

error:

DEBUG - asyncio: Using proactor: IocpProactor
...
    await self.open()
  File "C...\Cache\virtualenvs\transformer-wi-nHELc-py3.11\Lib\site-packages\azure\core\pipeline\transport\_aiohttp.py", line 127, in open
    await self.session.__aenter__()
          ^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute '__aenter__'. Did you mean: '__delattr__'?

Process finished with exit code 1

Metadata

Metadata

Labels

ClientThis issue points to a problem in the data-plane of the library.Service AttentionWorkflow: This issue is responsible by Azure service team.StorageStorage Service (Queues, Blobs, Files)customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-author-feedbackWorkflow: More information is needed from author to address the issue.no-recent-activityThere has been no recent activity on this issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions