I am attempting to upload a small file to gcloud using a simple python program
client = storage.Client(project=GCLOUD_PROJECT)
bucket = client.get_bucket(GCL
I solved this problem with:
pip install httplib2==0.15.0
pip install google-api-python-client==1.6
Edit: faster on load is: pip install httplib2==0.15.0 pip install google-api-python-client==1.7.11
I had this error on Dataflow (masquerading also as a BrokenPipe). Downgrading google-api-python-client
to the versions >=1.7.8,<1.7.12
fixed it, because 1.7.12 introduced a dependency on httplib2 0.17.0 which was somehow incompatible.
Downgrade your httplib2
version to 0.15.0
. Worked for me on the python google-cloud-sdk.
gcloud
package is deprecated twice and is not compatible with httplib2>=0.16
. Proper solution is to use google-cloud-*
packages family.
google-api-python-client>=1.7.12
is using redirect_codes API, please upgrade, it just works.
httplib2 v0.17.0 is just released with ability to modify set of response codes treated as redirects. This is the best option if you can modify code that creates Http
object:
http = httplib2.Http()
http.redirect_codes = http.redirect_codes - {308}
Iff that's not possible, edit your requirements.txt to pin down httplib2<0.16.0
google cloud storage server uses HTTP 308 for special resumable uploads feature which somewhat resembles "retry same method to same location", but not quite.
Above is (probably) rationale for PyPI package google-resumable-media which is used by more recent incarnations of gcloud related packages and handles 200 and 308 in similar manner, unlike generic HTTP client should.
History context:
google-cloud
Sorry for bad news. As HTTP enthusiast, I'm biased towards 308 support. Please reach if you have better idea how to handle this situation more gracefully.