Add context manager API to Key Vault clients - #9906
Merged
Merged
Conversation
bryevdv
reviewed
Feb 19, 2020
bryevdv
approved these changes
Feb 19, 2020
iscai-msft
reviewed
Feb 21, 2020
| client = CertificateClient(vault_url="https://localhost", credential=object(), transport=transport) | ||
|
|
||
| async with client: | ||
| assert transport.__aenter__.call_count == 1 |
Member
There was a problem hiding this comment.
Why is transport.aenter.call_count checked twice
Member
Author
There was a problem hiding this comment.
Paranoid thoroughness 😸
__aenter__ should only be called once. Possibly client.__aenter__ calls it twice, or client.__aexit__ calls it.
iscai-msft
approved these changes
Feb 21, 2020
This was referenced Mar 12, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
KeyVaultClientclass 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.