-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Add context manager API to Key Vault clients #9906
Conversation
client = CertificateClient(vault_url="https://localhost", credential=object(), transport=transport) | ||
|
||
async with client: | ||
assert transport.__aenter__.call_count == 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is transport.aenter.call_count checked twice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Paranoid thoroughness 😸
__aenter__
should only be called once. Possibly client.__aenter__
calls it twice, or client.__aexit__
calls it.
With this change Key Vault clients expose context manager APIs wrapping their autorest-generated clients (closes #7228). Implementing this would have required changes to the
KeyVaultClient
class wrapping those clients. Because that class is unnecessarily complex and the reason azure-keyvault-* depends on azure-common, I took this opportunity to replace it with simpler code (closes #8370).Sorry for the large diff. Most of it is duplicating shared code across libraries. You can filter out the "copy shared code" commit to hide all that.