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

Surface a way to update wrapped methods #1005

Open
tseaver opened this issue Oct 4, 2021 · 0 comments
Open

Surface a way to update wrapped methods #1005

tseaver opened this issue Oct 4, 2021 · 0 comments
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@tseaver
Copy link
Contributor

tseaver commented Oct 4, 2021

The generated retry policy and timeout for wrapped methods is not always suitable for every application (e.g., see googleapis/python-bigquery-storage#315). Rather than:

from google.api_core import exceptions
from google.api_core import retry

_retry_abort_unavailable = retry.if_exception_type(
    exceptions.Abort, exceptions.ServiceUnavailable,
)

transport = client.transport
wrapper = transport._wrapped_methods[transport.append_rows]
wrapper._retry._predicate = _retry_abort_unavailable

it would be nicer if we had a way to say:

transport = client.transport
old_wrapper = transport.wrapped_method(transport.append_row)
new_wrapper = old_wrapper.with_timeout(90)
new_wrapper.retry = new_wrapper.retry.with_predicate(_retry_abort_unavailable).with_deadline(900)
transport.wrap_method(transport.append_row, new_wrapper)
@tseaver tseaver added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. priority: p3 Desirable enhancement or fix. May not be included in next release. labels Oct 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

1 participant