Skip to content

Commit a62463c

Browse files
authored
fix: timeouts are handled by rest clients, retries silently ignored (#976)
1 parent d757358 commit a62463c

File tree

1 file changed

+7
-0
lines changed
  • gapic/templates/%namespace/%name_%version/%sub/services/%service/transports

1 file changed

+7
-0
lines changed

gapic/templates/%namespace/%name_%version/%sub/services/%service/transports/rest.py.j2

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ from typing import Callable, Dict, Optional, Sequence, Tuple
99
from google.api_core import operations_v1
1010
{% endif %}
1111
from google.api_core import gapic_v1 # type: ignore
12+
from google.api_core import retry as retries # type: ignore
1213
from google.api_core import exceptions as core_exceptions # type: ignore
1314
from google.auth import credentials as ga_credentials # type: ignore
1415
from google.auth.transport.grpc import SslCredentials # type: ignore
@@ -134,6 +135,8 @@ class {{ service.name }}RestTransport({{ service.name }}Transport):
134135

135136
def {{ method.name|snake_case }}(self,
136137
request: {{ method.input.ident }}, *,
138+
retry: retries.Retry = gapic_v1.method.DEFAULT,
139+
timeout: float = None,
137140
metadata: Sequence[Tuple[str, str]] = (),
138141
) -> {{ method.output.ident }}:
139142
r"""Call the {{- ' ' -}}
@@ -145,6 +148,9 @@ class {{ service.name }}RestTransport({{ service.name }}Transport):
145148
request (~.{{ method.input.ident }}):
146149
The request object.{{ ' ' }}
147150
{{- method.input.meta.doc|rst(width=72, indent=16) }}
151+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
152+
should be retried.
153+
timeout (float): The timeout for this request.
148154
metadata (Sequence[Tuple[str, str]]): Strings which should be
149155
sent along with the request as metadata.
150156
{% if not method.void %}
@@ -207,6 +213,7 @@ class {{ service.name }}RestTransport({{ service.name }}Transport):
207213
headers['Content-Type'] = 'application/json'
208214
response = self._session.{{ method.http_opt['verb'] }}(
209215
url,
216+
timeout=timeout,
210217
headers=headers,
211218
params=query_params,
212219
{% if 'body' in method.http_opt %}

0 commit comments

Comments
 (0)