You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Presently, we use httplib2 by default but allow users to specify their own http library (#908) so long as it conforms to httplib2.Http's signature.
httplib2 was chosen because it's the underlying http client used by google/oauth2client. However, httplib2 has a variety of issues include not being thread-safe (#1274), not doing any connection pooling, etc.
We should consider what it would take to move to another http library. The major considerations are:
We must support using oauth2client's credentials with the library. The essential functionality is adding the auth header and performing refresh & retry. This can be done either here or within oauth2client.
Does it make sense to have transports be a separate library all together?
nvm, the refresh logic is very oauth-centric so it doesn't quite make sense. Though I am curious what special considerations we'll need to make to use those transports in this library.
gcloud.streaming was for #935. We would have used apitools but it's future was unclear and it was (is?) completely undocumented. Hopefully we can strip down gcloud.streaming to just the core of what we need.
Your suggestion
>>>auth_http=AuthenticatedHttp(credentials)
is not agnostic of the transport. Instead you'd need
>>>auth_http=AuthenticatedHttp(credentials, http)
and you'd need a well-defined interface for http (e.g. defines http.request with signature same as httplib2.Http.request)
Sorry, I may not have been clear: AuthenticatedHttp is the transport - it's httplib2, whereas AuthenticatedSession would be a requests-based transport. Perhaps this is better:
Got it. I think it'd be easier to have a simple default that can use a httplib2.Http object with no modification and then maybe have libraries like oauth2client-urllib3 and oauth2client-requests that define the necessary interface.
I'm not a fan of httplib2's interface, and I think we'd be doing ourselves a disservice if we tried to make that our definition for the future.
Personally, I'd be in favor of dropping httplib2 altogether in favor of urllib3. Requests support would then be pretty straightforward. But that's pretty extreme and the waters for urllib3 and app engine are rocky.
Our transport for urllib3 could just be a wrapper around urlopen that does the authentication and refresh logic. Any other transport would need to implement the same urlopen interface.
Maybe it's better to put it this way: I think it's fine to let urllib3's poolmanager define our interface. We don't necessarily need to create any abstract classes or anything like that.
We don't necessarily need to create any abstract classes or anything like that.
I agree. I think it'd be nice just to allow someone to create any old transport they like and have it work with oauth2client provided it knew how to quack.
agree. I think it'd be nice just to allow someone to create any old transport they like and have it work with oauth2client provided it knew how to quack.
That's sort of the beauty of urllib3's design - the 'Manager' is the top-level component and there's currently multiple managers (e.g, ProxyManager, AppEngineManager, etc.).
What's the current status of thread-safety in the python APIs? #1214 was closed and redirected to this issue, but it'd be nice to have a clearer explanation of what's going on in this issue with respect to thread safety. FWIW https://developers.google.com/api-client-library/python/guide/thread_safety still mentions only httplib2 and a somewhat cumbersome workaround to ensure thread safety.
Reacted by mdmiller53, mdornseif, Dragos Harabor and Filip Dobrosavljevic
Hi @asilversempirical: @dhermes is in the process of moving us over to urllib3, which is thread-safe.
I actually thought there was an issue for this, but I can not find it, so I am reopening this one. :-)
Activity
dhermes commentedon Jan 5, 2016
As a start, it'd be nice to
oauth2clientto 100% code coverage (Get to 100% code coverage oauth2client#212)Credentials.authorize. Idea would be thatand
auth_http.requestwould perform the same functionality that the monkey-patched stuff wouldtheacodes commentedon Jan 5, 2016
What I would prefer even more:
Which would allow something like:
To be idiomatic.
theacodes commentedon Jan 5, 2016
Does it make sense to have transports be a separate library all together?
theacodes commentedon Jan 5, 2016
nvm, the refresh logic is very oauth-centric so it doesn't quite make sense. Though I am curious what special considerations we'll need to make to use those transports in this library.
theacodes commentedon Jan 5, 2016
Wow, there's a ton of code in
gcloud.streamingthat seems to be working around httplib2.What's the utility in continuing to support httplib2 directly? Could we move to urllib3 and be better served?
dhermes commentedon Jan 5, 2016
gcloud.streamingwas for #935. We would have usedapitoolsbut it's future was unclear and it was (is?) completely undocumented. Hopefully we can strip downgcloud.streamingto just the core of what we need.Your suggestion
is not agnostic of the transport. Instead you'd need
and you'd need a well-defined interface for
http(e.g. defineshttp.requestwith signature same ashttplib2.Http.request)theacodes commentedon Jan 5, 2016
Sorry, I may not have been clear:
AuthenticatedHttpis the transport - it's httplib2, whereasAuthenticatedSessionwould be a requests-based transport. Perhaps this is better:dhermes commentedon Jan 5, 2016
Got it. I think it'd be easier to have a simple default that can use a
httplib2.Httpobject with no modification and then maybe have libraries likeoauth2client-urllib3andoauth2client-requeststhat define the necessary interface.theacodes commentedon Jan 5, 2016
I'm not a fan of httplib2's interface, and I think we'd be doing ourselves a disservice if we tried to make that our definition for the future.
Personally, I'd be in favor of dropping httplib2 altogether in favor of urllib3. Requests support would then be pretty straightforward. But that's pretty extreme and the waters for urllib3 and app engine are rocky.
dhermes commentedon Jan 5, 2016
Now we're talking! 😀
Can you describe your desired interface?
theacodes commentedon Jan 5, 2016
Not sure yet. :)
Maybe something along the lines of how urllib3 does things already: the
urlopenmethod:Our transport for urllib3 could just be a wrapper around urlopen that does the authentication and refresh logic. Any other transport would need to implement the same urlopen interface.
theacodes commentedon Jan 5, 2016
Maybe it's better to put it this way: I think it's fine to let urllib3's
poolmanagerdefine our interface. We don't necessarily need to create any abstract classes or anything like that.dhermes commentedon Jan 5, 2016
Very similar to
httplib2.Http.request:also
google.appengine.api.urlfetch.fetchand
urllib2.urlopenin2.7.6and
urllib2.urlopenin2.7.10(latest as of Jan. 5, 2016)dhermes commentedon Jan 5, 2016
I agree. I think it'd be nice just to allow someone to create any old transport they like and have it work with
oauth2clientprovided it knew how to quack.theacodes commentedon Jan 5, 2016
That's sort of the beauty of urllib3's design - the 'Manager' is the top-level component and there's currently multiple managers (e.g, ProxyManager, AppEngineManager, etc.).
44 remaining items
asilversempirical commentedon Apr 19, 2017
What's the current status of thread-safety in the python APIs? #1214 was closed and redirected to this issue, but it'd be nice to have a clearer explanation of what's going on in this issue with respect to thread safety. FWIW https://developers.google.com/api-client-library/python/guide/thread_safety still mentions only httplib2 and a somewhat cumbersome workaround to ensure thread safety.
lukesneeringer commentedon Apr 19, 2017
Hi @asilversempirical:
@dhermes is in the process of moving us over to urllib3, which is thread-safe.
I actually thought there was an issue for this, but I can not find it, so I am reopening this one. :-)
dhermes commentedon Apr 19, 2017
@lukesneeringer I'd guess that issue was #1998
lukesneeringer commentedon Apr 19, 2017
Okay. Let's keep that one and close this one.
asilversempirical commentedon Apr 19, 2017
Thanks for the pointer!
chore(deps): update dependency setuptools to v63 (#1346)
chore: Remove six. (#1346)
chore(deps): update dependency certifi to v2022.6.15.1 (#1346)
feat: add integration test for universe domain (#1346)
docs: migrate code from googleapis/python-bigquery (#18303)