-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 google.api.core.timeout #3858
Conversation
Towards #3842 |
8959847
to
2f5eb0f
Compare
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.
Mostly LGTM
core/google/api/core/timeout.py
Outdated
|
||
for n in range(10): | ||
try: | ||
is_thing_ready({'example': 'data'}) |
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/api/core/timeout.py
Outdated
_DEFAULT_INITIAL_TIMEOUT = 5.0 # seconds | ||
_DEFAULT_MAXIMUM_TIMEOUT = 30.0 # seconds | ||
_DEFAULT_TIMEOUT_MULTIPLIER = 2.0 | ||
_DEFAULT_DEADLINE = None # seconds |
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.
Yields: | ||
float: A timeout value. | ||
""" | ||
if deadline is not None: |
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/api/core/timeout.py
Outdated
datetime_helpers.utcnow() + | ||
datetime.timedelta(seconds=deadline)) | ||
else: | ||
deadline = datetime.datetime.max |
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/api/core/timeout.py
Outdated
|
||
@six.python_2_unicode_compatible | ||
class ExponentialTimeout(object): | ||
"""A decorator that adds a exponentially increasing timeout argument. |
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.
@six.wraps(func) | ||
def func_with_timeout(*args, **kwargs): | ||
"""Wrapped function that adds timeout.""" | ||
kwargs['timeout'] = next(timeouts) |
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.
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.
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.
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.
LGTM
No description provided.