Skip to content

Commit

Permalink
feat: add context manager support in client (#146)
Browse files Browse the repository at this point in the history
- [ ] Regenerate this pull request now.

chore: fix docstring for first attribute of protos

committer: @busunkim96
PiperOrigin-RevId: 401271153

Source-Link: googleapis/googleapis@787f8c9

Source-Link: googleapis/googleapis-gen@81decff
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiODFkZWNmZmU5ZmM3MjM5NmE4MTUzZTc1NmQxZDY3YTZlZWNmZDYyMCJ9
  • Loading branch information
gcf-owl-bot[bot] authored Oct 8, 2021
1 parent d62d449 commit 7725ff4
Show file tree
Hide file tree
Showing 8 changed files with 187 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6240,6 +6240,12 @@ async def update_data_retention_settings(
# Done; return the response.
return response

async def __aenter__(self):
return self

async def __aexit__(self, exc_type, exc, tb):
await self.transport.close()


try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -621,10 +621,7 @@ def __init__(
client_cert_source_for_mtls=client_cert_source_func,
quota_project_id=client_options.quota_project_id,
client_info=client_info,
always_use_jwt_access=(
Transport == type(self).get_transport_class("grpc")
or Transport == type(self).get_transport_class("grpc_asyncio")
),
always_use_jwt_access=True,
)

def get_account(
Expand Down Expand Up @@ -6745,6 +6742,19 @@ def update_data_retention_settings(
# Done; return the response.
return response

def __enter__(self):
return self

def __exit__(self, type, value, traceback):
"""Releases underlying transport's resources.
.. warning::
ONLY use as a context manager if the transport is NOT shared
with other clients! Exiting the with block will CLOSE the transport
and may cause errors in other clients!
"""
self.transport.close()


try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,15 @@ def _prep_wrapped_messages(self, client_info):
),
}

def close(self):
"""Closes resources associated with the transport.
.. warning::
Only call this method if the transport is NOT shared
with other clients - this may cause errors in other clients!
"""
raise NotImplementedError()

@property
def get_account(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2615,5 +2615,8 @@ def update_data_retention_settings(
)
return self._stubs["update_data_retention_settings"]

def close(self):
self.grpc_channel.close()


__all__ = ("AnalyticsAdminServiceGrpcTransport",)
Original file line number Diff line number Diff line change
Expand Up @@ -2673,5 +2673,8 @@ def update_data_retention_settings(
)
return self._stubs["update_data_retention_settings"]

def close(self):
return self.grpc_channel.close()


__all__ = ("AnalyticsAdminServiceGrpcAsyncIOTransport",)
Loading

0 comments on commit 7725ff4

Please sign in to comment.