Skip to content

Unclosed client session in azure.containerregistry.aio.ContainerRegistryClient.list_repository_names #20000

Description

  • Package Name: azure-containerregistry==1.0.0b4, azure-core==1.16.0, azure-identity==1.6.0
  • Operating System: OS X
  • Python Version: Python 3.9.4

Describe the bug
Using azure.containerregistry.aio.ContainerRegistryClient.list_repository_names results in the following aiohttp warning:

Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x10b264ee0>
Unclosed connector
connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x10b2e84c0>, 1.472941262)]']
connector: <aiohttp.connector.TCPConnector object at 0x10b3020a0>

To Reproduce
Based on the sample from https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/containerregistry/azure-containerregistry/samples/async_samples/sample_delete_old_tags_async.py I do run the following:

import asyncio
import os


class ListOperations(object):
    def __init__(self, account_url=None):
        if account_url is None:
            self.account_url = os.environ["CONTAINERREGISTRY_ENDPOINT"]
        else:
            self.account_url = account_url

    async def print_repository(self):
        from azure.containerregistry.aio import (
            ContainerRegistryClient,
        )
        from azure.identity.aio import AzureCliCredential

        credential = AzureCliCredential()
        client = ContainerRegistryClient(self.account_url, credential)

        async with client:
            async for repository in client.list_repository_names():
                print(repository)


async def main():
    sample = ListOperations()
    await sample.print_repository()


if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())

Expected behavior
There is no warning about unclosed sessions and connectors.

Metadata

Metadata

Labels

ClientThis issue points to a problem in the data-plane of the library.Container RegistrybugThis issue requires a change to an existing behavior in the product in order to be resolved.customer-reportedIssues that are reported by GitHub users external to the Azure organization.issue-addressedWorkflow: The Azure SDK team believes it to be addressed and ready to close.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions