Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aiohttp SecretClient not closing session. #16757

Closed
cyberpion-yotam opened this issue Feb 16, 2021 · 3 comments · Fixed by #16793
Closed

aiohttp SecretClient not closing session. #16757

cyberpion-yotam opened this issue Feb 16, 2021 · 3 comments · Fixed by #16793
Assignees
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. Docs KeyVault
Milestone

Comments

@cyberpion-yotam
Copy link

  • Package Name: azure-keyvault-secrets
  • Package Version: 4.2.0
  • Operating System: Ubuntu 18
  • Python Version: 3.8

Describe the bug
When running is Azure Functions, after using the aio SecretClient's context manager, I receive the following error:

Unclosed connector connections: [[(<aiohttp.client_proto.ResponseHandler object at 0x7f274ad97e80>, 1654.2421122)]] connector: <aiohttp.connector.TCPConnector object at 0x7f274adc00d0>

I am aware this bug was "fixed" here: #8990

I have followed the instructions here: https://docs.microsoft.com/en-us/python/api/overview/azure/keyvault-keys-readme?view=azure-python#async-api

To Reproduce
Steps to reproduce the behavior:

  1. Create an Azure function (timer triggered in my case)
  2. Use the aio SecretClient and DefaultAzureCredential using a context manager
from azure.identity.aio import DefaultAzureCredential
from azure.keyvault.secrets.aio import SecretClient
async def main(...):
    credential = DefaultAzureCredential()
    client = SecretClient(KEY_VAULT_URL, credential=credential)
    async with client:
        # Use client
  1. Run with func start or in a deployed Azure Function

Expected behavior
Azure function success.

Actual behavior
I get the following error after execution:

Unclosed connector connections: [[(<aiohttp.client_proto.ResponseHandler object at 0x7f274ad97e80>, 1654.2421122)]] connector: <aiohttp.connector.TCPConnector object at 0x7f274adc00d0>

Screenshots
image

@ghost ghost added needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Feb 16, 2021
@cyberpion-yotam
Copy link
Author

Ended up finding out you need to close the Credential as well.
So:

from azure.identity.aio import DefaultAzureCredential
from azure.keyvault.secrets.aio import SecretClient
async def main(...):
    credential = DefaultAzureCredential()
    client = SecretClient(KEY_VAULT_URL, credential=credential)
    async with client, credential:
        # Use client

Could maybe be added to the docs (seems like a pretty integral part of using the SecretClient)

@xiangyan99 xiangyan99 added bug This issue requires a change to an existing behavior in the product in order to be resolved. Client This issue points to a problem in the data-plane of the library. Docs KeyVault labels Feb 16, 2021
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Feb 16, 2021
@xiangyan99 xiangyan99 removed the question The issue doesn't require a change to the product in order to be resolved. Most issues start as that label Feb 16, 2021
@xiangyan99 xiangyan99 added this to the [2021] March milestone Feb 16, 2021
@xiangyan99
Copy link
Member

Thanks for the feedback, we’ll investigate asap.

@chlowell
Copy link
Member

Glad you figured it out, and I agree it's worth documenting. I've opened #16793 to do that. Thanks for this issue!

@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. Docs KeyVault
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants