-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add operation future #3618
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
Add operation future #3618
Conversation
| Args: | ||
| operation (dict): Operation as a dictionary. | ||
| api_request (Callable): A callable used to make an API request. This |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
lukesneeringer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems fine to me. No issues adding tenacity.
dhermes
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
High-level: Do LRO RPC services give trailers describing when to retry?
| 'google-auth >= 0.4.0, < 2.0.0dev', | ||
| 'google-auth-httplib2', | ||
| 'six', | ||
| 'tenacity >= 4.0.0, <5.0.0dev' |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| """Abstract and helper bases for Future implementations.""" | ||
|
|
||
| import abc | ||
| import concurrent.futures |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
core/google/cloud/future/base.py
Outdated
| The private :meth:`_blocking_poll` method should be implemented by | ||
| subclasses. | ||
| The private :meth:`done` method should be implemented by |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| """ | ||
| # pylint: disable=missing-raises | ||
| raise NotImplementedError() | ||
| if self._result_set: |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
core/google/cloud/future/base.py
Outdated
| if self._result_set: | ||
| return | ||
|
|
||
| retry_on = tenacity.retry_if_result(lambda result: result is not True) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| self.set_exception(exception) | ||
| else: | ||
| exception = exceptions.GoogleCloudError( | ||
| 'Unknown operation error') |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| bool: True if the operation is complete, False otherwise. | ||
| """ | ||
| operation = self._refresh_and_update() | ||
| return operation.done |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| Args: | ||
| operation (dict): Operation as a dictionary. | ||
| api_request (Callable): A callable used to make an API request. This |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| Args: | ||
| operation (dict): Operation as a dictionary. | ||
| api_request (Callable): A callable used to make an API request. This | ||
| should generally be an instance of |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| to a given API) vis `HTTP/JSON`_. | ||
| .. _HTTP/JSON: https://cloud.google.com/speech/reference/rest/\ | ||
| v1beta1/operations#Operation |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| exception = exceptions.GoogleCloudError( | ||
| 'Unknown operation error') | ||
| 'Unexpected state: Long-running operation had neither ' | ||
| 'response nor error set.') |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
@dhermes the latest release of resumable-media seems to have broken circle. Do you want me to hold off on merging this until you can resolve that? (Master will be broken by it either way). |
|
Rebased and waiting on CI to merge. |
Note: This adds a dependency on the
tenacitylibrary. It's worth it.Towards #3617