Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0ee82e0

Browse files
committed
feat: Add OperationsRestAsyncTransport to support long running operations
1 parent3f26e81 commit0ee82e0

File tree

5 files changed

+575
-14
lines changed

5 files changed

+575
-14
lines changed

‎google/api_core/operations_v1/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,21 @@
2121
fromgoogle.api_core.operations_v1.operations_clientimportOperationsClient
2222
fromgoogle.api_core.operations_v1.transports.restimportOperationsRestTransport
2323

24+
try:
25+
fromgoogle.api_core.operations_v1.transports.rest_asyncioimport (
26+
OperationsRestAsyncTransport,
27+
)
28+
29+
HAS_ASYNC_TRANSPORT=True
30+
exceptImportError:
31+
# Don't raise an exception if `OperationsRestAsyncTransport` cannot be imported
32+
# so that OperationsRestTransport can still be imported
33+
HAS_ASYNC_TRANSPORT=False
34+
2435
__all__= [
2536
"AbstractOperationsClient",
2637
"OperationsAsyncClient",
2738
"OperationsClient",
2839
"OperationsRestTransport",
40+
"OperationsRestAsyncTransport",
2941
]

‎google/api_core/operations_v1/transports/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,24 @@
1818
from .baseimportOperationsTransport
1919
from .restimportOperationsRestTransport
2020

21+
try:
22+
from .rest_asyncioimportOperationsRestAsyncTransport
23+
24+
HAS_ASYNC_TRANSPORT=True
25+
exceptImportError:
26+
# Don't raise an exception if `OperationsRestAsyncTransport` cannot be imported
27+
# so that OperationsRestTransport can still be imported
28+
HAS_ASYNC_TRANSPORT=False
2129

2230
# Compile a registry of transports.
2331
_transport_registry=OrderedDict()
2432
_transport_registry["rest"]=OperationsRestTransport
2533

34+
ifHAS_ASYNC_TRANSPORT:
35+
_transport_registry["rest_asyncio"]=OperationsRestAsyncTransport
36+
2637
__all__= (
2738
"OperationsTransport",
2839
"OperationsRestTransport",
40+
"OperationsRestAsyncTransport",
2941
)

‎google/api_core/operations_v1/transports/base.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
fromgoogle.api_coreimportexceptionsascore_exceptions# type: ignore
2121
fromgoogle.api_coreimportgapic_v1# type: ignore
2222
fromgoogle.api_coreimportretryasretries# type: ignore
23+
fromgoogle.api_coreimportretry_asyncasretries_async# type: ignore
2324
fromgoogle.api_coreimportversion
2425
importgoogle.auth# type: ignore
2526
fromgoogle.authimportcredentialsasga_credentials# type: ignore
@@ -115,12 +116,13 @@ def __init__(
115116
# Save the credentials.
116117
self._credentials=credentials
117118

118-
def_prep_wrapped_messages(self,client_info):
119+
def_prep_wrapped_messages(self,client_info,is_async=False):
119120
# Precompute the wrapped methods.
121+
retry_class=retries_async.AsyncRetryifis_asyncelseretries.Retry
120122
self._wrapped_methods= {
121123
self.list_operations:gapic_v1.method.wrap_method(
122124
self.list_operations,
123-
default_retry=retries.Retry(
125+
default_retry=retry_class(
124126
initial=0.5,
125127
maximum=10.0,
126128
multiplier=2.0,
@@ -135,7 +137,7 @@ def _prep_wrapped_messages(self, client_info):
135137
),
136138
self.get_operation:gapic_v1.method.wrap_method(
137139
self.get_operation,
138-
default_retry=retries.Retry(
140+
default_retry=retry_class(
139141
initial=0.5,
140142
maximum=10.0,
141143
multiplier=2.0,
@@ -150,7 +152,7 @@ def _prep_wrapped_messages(self, client_info):
150152
),
151153
self.delete_operation:gapic_v1.method.wrap_method(
152154
self.delete_operation,
153-
default_retry=retries.Retry(
155+
default_retry=retry_class(
154156
initial=0.5,
155157
maximum=10.0,
156158
multiplier=2.0,
@@ -165,7 +167,7 @@ def _prep_wrapped_messages(self, client_info):
165167
),
166168
self.cancel_operation:gapic_v1.method.wrap_method(
167169
self.cancel_operation,
168-
default_retry=retries.Retry(
170+
default_retry=retry_class(
169171
initial=0.5,
170172
maximum=10.0,
171173
multiplier=2.0,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp