-
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
Magically take care of threading issues, please. #926
Comments
+1 I really like this idea |
I like the idea too, but it is pretty abstract. Can you give an example where you have to deal with threading that you'd like the library to handle? |
Yes, when I'm calling the code on app engine, my http handlers will be called from multiple threads. I can't share a connection/http object between them all because the underlying http object is not thread safe. I don't want to create a new http object for each request because then I lose the benefit of connection: keep-alive. |
Also, I don't want to create a new http object for each request because then it has to re-authenticate. |
In the short term I'd like to point to #908 and the custom code there using We'd like to address this, but if your needs are pressing, you may be happy with a short-term hack in the style described in that issue. |
Given that we are moving to re-bind domain objects to clients (where clients encapsulate a connection), satisfying this goal is going to be tricky, unless the "foreign" thread is willing to pass in its client to methods which need a client. |
Pinging this issue as threadsafety for gcloud clients recently came up in discussion. What's the status on this? Are client objects not threadsafe? If not, what needs to be done to allow that? Also, if not, can we explicitly document that? |
I think the best way to know is to write threaded code and see what happens. Anyone want to volunteer? |
tentatively raises hand I'll give a shot when I get a bit of free time. |
I do know a little bit about this. For one, We already enable this with our library (#908) but it doesn't solve the auth problem for people until |
I coped with this issue by using thread-local instances of httplib2.Http. |
@SurferJeffAtGoogle It may be "faster" to avoid calling We could manually add a connection or client pool that just binds to a thread local for the user? |
I would be in favor of this. |
is my inspiration for such a thing. |
I was going to recommend peeking at urllib3, but that's actually quite nice and short. |
Well the long-term goal is to divorce ourselves from the transport layer in a clean way, but that also relies on googleapis/oauth2client#128 as well |
Ah, sorry, I was unclear, I just meant to take urllib3's connection pooling as an example. I like happybase's approach. Is it possible for us to more or less hide this from the user? |
Yes I think we can hide it in the |
I like "hiding it in the Client constructor." If we use thread locals, I don't understand the advantage of also using a pool. Is that for when a thread terminates its thread local falls back into the pool? I have no idea what the lifetime of a thread on app engine looks like. |
The idea would be that the pool creates a thread local connection for the client to use: |
Ok. That looks good. |
Just a bump on this. Today I just noticed that one of my projects assumed client was threadsafe, and proceeded to explode. |
Could we not do something as trivial as have |
I'm teaching a course this week. I'm happy to review PRs in the evening? |
I'll be traveling, but I can see what I can do next week (which is my last On Mon, Dec 7, 2015, 6:30 PM Danny Hermes [email protected] wrote:
|
Fixes googleapis#926, and opens up the possibility of using an object pool later.
Fixes googleapis#926, and opens up the possibility of using an object pool later.
Fixes googleapis#926, and opens up the possibility of using an object pool later.
Fixes googleapis#926, and opens up the possibility of using an object pool later.
Fixes googleapis#926, and opens up the possibility of using an object pool later.
Fixes googleapis#926, and opens up the possibility of using an object pool later.
Fixes googleapis#926, and opens up the possibility of using an object pool later.
Fixes googleapis#926, and opens up the possibility of using an object pool later.
Fixes googleapis#926, and opens up the possibility of using an object pool later.
Superseded by the discussion over at #1346 |
I don't want to worry about connections and threads. I want to be able to pass API classes from thread to thread and have the classes take care of threading issues.
The text was updated successfully, but these errors were encountered: