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

Allow using ConsumptionManagementClient as a context manager for HTTPS connections reuse #239

Open
pdecat opened this issue Apr 10, 2021 · 0 comments

Comments

@pdecat
Copy link

pdecat commented Apr 10, 2021

Hi,

it would be awesome if ConsumptionManagementClient could be used as a context manager just like ComputeClientManagement.

Currently, this does not work as ConsumptionManagementClient only inherits from object and has no __enter__/__exit__ methods, unlike ComputeClientManagement that does inherit from msrest.service_client.SDKClient:

consumption_client = ConsumptionManagementClient(**parameters)
with consumption_client as client:
  response = client.price_sheet.get(expand="meterDetails", raw=True) 

A dirty work-around that works:

consumption_client = ConsumptionManagementClient(**parameters)
with consumption_client._client:
  response = consumption_client.price_sheet.get(expand="meterDetails", raw=True) 

Related: #132 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant