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
Thread safe of httplib2 and credentials -> update Documentation #808
Comments
@DopeforHope Thanks for the detailed report! It looks like our docs need to be updated to explain how to authorize the httplib2 instances. |
@busunkim96 please do so |
Is this really relevant? https://github.com/googleapis/google-api-python-client/blob/master/googleapiclient/discovery.py#L237 On build() it looks like it calls build_http() which also creates a new httplib2.Http() object. Each thread for me has a separate build() call. (Each client => one build() => one thread) |
Hi, I experienced the same problem. Unfortunately on my case, I cannot |
After digging up the source code, I found this in
So I think I can just do something like this:
UPDATE: This works for me. Although I'd still love to hear from google engineers if this is a recommended approach |
Closes #808 Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [x] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/google-api-python-client/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [x] Ensure the tests and linter pass - [x] Code coverage does not decrease (if any source code was changed) - [x] Appropriate docs were updated (if necessary) Fixes #808 🦕
🤖 I have created a release \*beep\* \*boop\* --- ### [1.12.8](https://www.github.com/googleapis/google-api-python-client/compare/v1.12.7...v1.12.8) (2020-11-18) ### Documentation * add httplib2 authorization to thread_safety ([#1005](https://www.github.com/googleapis/google-api-python-client/issues/1005)) ([205ae59](https://www.github.com/googleapis/google-api-python-client/commit/205ae5988bd89676823088d6c8a7bd17e3beefcf)), closes [#808](https://www.github.com/googleapis/google-api-python-client/issues/808) [#808](https://www.github.com/googleapis/google-api-python-client/issues/808) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please).
So right now I'm using your library with multiple threads.
Due to the fact that httplib2 is not thread safe I tried to use your examples.
But either way I have the problem that the threads are not authenticated. In the documentation is nothing like this mentioned.
I tried just building an own
httplib2.Http()
object for every thread at the beginning of it and also tried the approach of overriding the defaultrequestBuilder
of the service which I used across all threads but nothing worked due to authentification issues.In the end it worked for me that I just executed the following
authenticate_and_build_service()
function for every thread. This function basically return a newservice
object via thebuild('drive', 'v3', credentials=creds)
.Nevertheless I'm not sure if it has any downsides of building a
service
object for every thread and it would be nice if someone could comment on this and maybe even update the documentation.I also didn't find a way in the
execute()
function to specify credentials.The text was updated successfully, but these errors were encountered: