Thread-safe client functionality for gcloud-python via requests.
pip install --upgrade gcloud_requests
Note that at this time, only gcloud==0.17.0
on Python 2.7 is
officially supported.
The library provides new HTTP objects that can be passed in to the
gcloud.*.Client
constructors (per supported API module). For example,
to use the connection class (with proper retrying implemented) for
Google Cloud Datastore:
from gcloud import datastore
from gcloud_requests.connection import datastore_http
client = datastore.Client(http=datastore_http)
client.query(kind="EntityKind").fetch()
and for the Google Cloud Storage service:
from gcloud import storage
from gcloud_requests.connection import storage_http
client = storage.Client(http=storage_http, project="my-project")
bucket = client.get_bucket("my-bucket")
Using a custom HTTP object causes gcloud Clients to ignore whatever
Credentials objects you pass into them manually. If you need to use a
custom set of credentials with gcloud_requests
you must instantiate
a RequestsProxy
object by passing in those credentials and then
passing that instance to your client like so:
from gcloud import datastore
from gcloud_requests.requests_connection import DatastoreRequestsProxy
http = DatastoreRequestsProxy(custom_credentials)
client = datastore.Client(http=http)
The gcloud-python library for accessing Google Cloud
Platform services like Google Cloud Datastore, Google Cloud Storage,
Google BigQuery, and others, relies on the httplib2
library to handle
the underlying Protobuf requests. This library (httplib2
) is not
threadsafe.
Based on notes in gcloud-python#926, gcloud-python#908,
and gcloud-python#1214, this library replaces the
underlying transport with requests
.
It's strongly encouraged that you let Travis run the tests. This is
because running the tests requires gcd
, the Google Cloud Datastore
tools, which also requires a Google Cloud Platform service key...if
you're still intrigued, work through the gcd documentation
and
then simply install pytest
and run the tests with py.test
.
gcloud_requests
was authored at Leadpages. You can
find out more about contributors here. We welcome
contributions, and we're always looking for more
engineering talent!
Please read our contributor's guide.