-
-
Notifications
You must be signed in to change notification settings - Fork 866
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
[gcloud] Add a setting for connect/read timeouts #1120
base: master
Are you sure you want to change the base?
Conversation
0772017
to
4ee9405
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.
This looks like a good change. (I have not run it yet)
I made a few minor comments/suggestions.
@@ -34,7 +34,7 @@ def __init__(self, name, mode, storage): | |||
self.mime_type = mimetypes.guess_type(name)[0] | |||
self._mode = mode | |||
self._storage = storage | |||
self.blob = storage.bucket.get_blob(name) | |||
self.blob = storage.bucket.get_blob(name, timeout=storage.timeout) |
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.
nit: you use time=storage.timeout
here, but elsewhere in same function you use timeout=self._storage.timeout
I realize they are the same, but better to be consistent.
Sometimes requests can get stuck, so it's better if the timeout is low, couple of seconds. This means that a new request | ||
(via retry) will be made sooner. The default is higher to keep the behavior from before this setting was introduced. | ||
|
||
Timeouts will be automatically retried when using `google-cloud-storage` version that includes |
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.
google-cloud-storage
> 2.2.0
bytes sent from the server. If float is given it's applied to both, if a tuple – the first value is for the connect | ||
timeout, second for read. | ||
|
||
Note that read timeout =/= download timeout. It’s the number of seconds that the client will wait *between* bytes sent |
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.
Did you mean ≠ ?
I was not sure what =/= meant.
@@ -38,9 +38,9 @@ def test_open_read(self): | |||
|
|||
f = self.storage.open(self.filename) | |||
self.storage._client.bucket.assert_called_with(self.bucket_name) | |||
self.storage._bucket.get_blob.assert_called_with(self.filename) |
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.
maybe define the DEFAULT_TIMEOUT=60
and use it instead of the 60
in the test. It will make the tests easier to update if the default is ever changed. It also make it very explicit what is going on.
The default that is set by the google lib is 60 seconds, which is unnecessarily high. See docs in this change for explanation why.