Comments (8)
yes, apiclient
is tied to httplib2
, which isn't threadsafe. if you make separate httplib2.Http
instances per thread, you'll hit less trouble.
the right answer here is to switch to something like requests
, but that's quite a large change.
from google-api-python-client.
Can you point me in the right direction on doing that? Thanks!
from google-api-python-client.
on the "separate instances per thread", do you control thread creation in flask or does it handle it for you?
on the "switch to requests" front, we need to start with oauth2client. this is an extremely involved set of changes.
from google-api-python-client.
I dug around with switching to requests, but ultimately decided it was just going to be too much for me to handle. Would be great though.
Flask controls thread creation. Any way to just pass in the new httplib2.Http
object on execute()
?
from google-api-python-client.
yeah, the requests switch is a pretty serious set of changes. i've been hoping to start on it in oauth2client for almost a year now, and it's always "ooh ... that looks serious."
execute()
actually already does take an optional http
argument; probably the one hitch is that you need to make sure it's authorized.
from google-api-python-client.
Yeah, just tried that it was the problem I ran into. Any way to transfer the authorization from the default http
argument to a newly initialized one?
from google-api-python-client.
it's a little convoluted, but you could do
client.something().something().execute(http=client.http.credentials.authorize(http=httplib2.Http()))
however, you might need to create the Http
instance as a thread local? in any event, the old http
has a handle on the credentials used to authorize it, which you can use here.
here we're moving the problem around a little -- multiple threads trying to refresh the credentials at once may hit trouble -- but it's less problematic than multiple threads sharing the same http connection pool (which is always bad juju).
from google-api-python-client.
That worked, thanks!
from google-api-python-client.
Related Issues (20)
- Google Drive API v3: .export_media() doesn't work for big sheets
- ☆☆
- Update Discovery cache
- .
- Cloud Run Job v2 API does not include the `force` query parameter for Jobs.Delete HOT 1
- How can I be able to upload ".webp" files to my Google Cloud bucket, if I am using python 2.7 and 1.5.3 version of api-client? HOT 1
- Projects Data Entry use Python to CSV format HOT 1
- Events returned for Calendar outside of the timeMin and timeMax range HOT 1
- `MediaIoBaseDownload` does not support downloading google sheet objects > 10MB HOT 2
- User customSchemas patching or updating fails when attribute is not multivalued HOT 2
- Discovery caching with file_cache is unsupported HOT 2
- CONTRIBUTING.rst mentions outdated "nox -s docs" command
- Deprecated utcnow, utcfromtimestamp should be removed
- Main
- Update or remove docs/epy
- urllib3 seems to consider the endpoint as the http method HOT 2
- MediaIoBaseDownload Cannot Handle Resuming Partial Download HOT 2
- Payment option is invisible the option HOT 1
- Compressing the discovery cache HOT 1
- Einträge verwalten
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from google-api-python-client.