-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Make connection return a thread-local instance of http. #1274
Conversation
@dhermes this is a "basic" fix for #926. It has the drawback that a new We can open up a new bug to create a thread-local object pool and use it to provide http objects. |
@@ -55,6 +56,8 @@ class Connection(object): | |||
object will also need to be able to add a bearer token to API | |||
requests and handle token refresh on 401 errors. | |||
|
|||
A custom `http` object will also need to ensure its own thread safety. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
I think I like it but I'm scared |
363dcda
to
01bf3f5
Compare
Agreed. Though, this is the Simplest Thing That Works™. Pooling is a better (more memory/resource friendly) way to do it, but as I said we can take small steps towards that. |
7daeccf
to
8417e64
Compare
@tseaver Can you weigh in? This will have big implications |
@@ -66,6 +67,26 @@ def test_user_agent_format(self): | |||
conn = self._makeOne() | |||
self.assertEqual(conn.USER_AGENT, expected_ua) | |||
|
|||
def test_thread_local_http(self): | |||
credentials = _Credentials(lambda x: object()) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
6836a46
to
99daaaf
Compare
self.assertEqual(len(http_objs), 2) | ||
self.assertTrue(http_objs[0] is not http_objs[1]) | ||
self.assertTrue(http_objs[0] is not http_main) | ||
self.assertTrue(http_objs[1] is not http_main) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Fixes googleapis#926, and opens up the possibility of using an object pool later.
99daaaf
to
7148ef7
Compare
No this PR is not obsolete. We won't be fixing |
Gotcha. Let me know if there's anything I need to do to move this along. |
Was waiting to hear from @tseaver. I think I'd prefer us writing a custom |
Sounds somewhat reasonable, though what sounds even more reasonable is just using urllib3. Not sure how you feel about that. Either way, can we do it with another bug/PR? |
I am all for it, but we need to make |
SGTM. In a related effort, I've been trying to make sure urllib3 works on App Engine. |
Ha! Very nice. |
@jonparrott It does (mostly) though it will use Edit: |
@bendemaree it's now configurable, and there's a PR to requests-toolbelt to enable ongoing support for GAE. Regardless, I think it's better to do this now, then discuss how we want to support other http libraries in another bug. |
Let's continue the discussion around the http library/transport over at #1346. |
OK |
@jonparrott Excellent info, thank you. 👍 |
@jonparrott Shall we close this PR? |
Yeah On Fri, Sep 23, 2016, 3:25 PM Danny Hermes notifications@github.com wrote:
|
In my case..i fixed the thing with NOT using the shared connection..and downloading files in chunks async from cloud storage. |
Fixes #926, and opens up the possibility of using an object pool later.