GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Magically take care of threading issues, please. · Issue #926 · googleapis/google-cloud-python

Magically take care of threading issues, please. #926

New issue
Copy link
New issue
Copy link
Closed
Closed
Magically take care of threading issues, please.#926
Copy link
Assignees
theacodes
Labels
api: core

Description

@SurferJeffAtGoogle
SurferJeffAtGoogle
opened on Jun 17, 2015
Issue body actions

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.

Activity

Next
  1. tmatsuo commented on Jun 17, 2015

    @tmatsuo
    tmatsuo
    on Jun 17, 2015
    Contributor
    More actions

    +1 I really like this idea

  2. dhermes
    added
    api: core
    on Jun 17, 2015
  3. dhermes
    added this to the This milestone has been deleted milestone on Jun 17, 2015
  4. dhermes commented on Jun 17, 2015

    @dhermes
    dhermes
    on Jun 17, 2015
    Contributor
    More actions

    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?

  5. SurferJeffAtGoogle commented on Jun 17, 2015

    @SurferJeffAtGoogle
    SurferJeffAtGoogle
    on Jun 17, 2015
    ContributorAuthor
    More actions

    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.

  6. SurferJeffAtGoogle commented on Jun 17, 2015

    @SurferJeffAtGoogle
    SurferJeffAtGoogle
    on Jun 17, 2015
    ContributorAuthor
    More actions

    Also, I don't want to create a new http object for each request because then it has to re-authenticate.

  7. dhermes commented on Jun 17, 2015

    @dhermes
    dhermes
    on Jun 17, 2015
    Contributor
    More actions

    In the short term I'd like to point to #908 and the custom code there using requests.

    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.

  8. tseaver commented on Jun 23, 2015

    @tseaver
    tseaver
    on Jun 23, 2015
    Contributor
    More actions

    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.

  9. dhermes commented on Jun 23, 2015

    @dhermes
    dhermes
    on Jun 23, 2015
    Contributor
    More actions

    A bigger issue may also be that httplib2 is not thread-safe. @tseaver You should check out how easily @mwitkow-io was able to make requests work in our library in a threaded environment in #908.

  10. theacodes commented on Sep 25, 2015

    @theacodes
    theacodes
    on Sep 25, 2015
    Contributor
    More actions

    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?

  11. dhermes commented on Sep 25, 2015

    @dhermes
    dhermes
    on Sep 25, 2015
    Contributor
    More actions

    I think the best way to know is to write threaded code and see what happens. Anyone want to volunteer?

  12. theacodes commented on Sep 25, 2015

    @theacodes
    theacodes
    on Sep 25, 2015
    Contributor
    More actions

    tentatively raises hand

    I'll give a shot when I get a bit of free time.

  13. dhermes commented on Sep 25, 2015

    @dhermes
    dhermes
    on Sep 25, 2015
    Contributor
    More actions

    I do know a little bit about this. For one, httplib2 is not thread safe. I have been advocating for a "divorce" from httplib2 or at least a way to give people other options (see googleapis/oauth2client#128). I feel like large structural changes should wait until googleapis/oauth2client#212 is complete though.

    We already enable this with our library (#908) but it doesn't solve the auth problem for people until oauth2client catches up.

  14. SurferJeffAtGoogle commented on Sep 25, 2015

    @SurferJeffAtGoogle
    SurferJeffAtGoogle
    on Sep 25, 2015
    ContributorAuthor
    More actions

    I coped with this issue by using thread-local instances of httplib2.Http.
    https://github.com/GoogleCloudPlatform/pubsub-shout-csharp/blob/master/appengine-python-flask/pubsub.py

  15. dhermes commented on Sep 25, 2015

    @dhermes
    dhermes
    on Sep 25, 2015
    Contributor
    More actions

    @SurferJeffAtGoogle It may be "faster" to avoid calling credentials = oauth2client.GoogleCredentials.get_application_default() in every single thread, but I think it's not so bad an approach.

    We could manually add a connection or client pool that just binds to a thread local for the user?

  16. 25 remaining items

  17. atulep
    added 2 commits that reference this issue on Apr 6, 2023

    Fix typo [(#926)](GoogleCloudPlatform/python-docs-samples#926)

    ab63cb8

    Fix typo [(#926)](GoogleCloudPlatform/python-docs-samples#926)

    9c4bf63
  18. atulep
    added a commit that references this issue on Apr 18, 2023

    Fix typo [(#926)](GoogleCloudPlatform/python-docs-samples#926)

    6763d8a
  19. parthea
    added a commit that references this issue on Oct 22, 2023

    Fix typo [(#926)](GoogleCloudPlatform/python-docs-samples#926)

    99e7123
  20. parthea
    added a commit that references this issue on Sep 18, 2025

    chore(main): release 0.29.0 (#926)

    e40e7ae
  21. parthea
    added 5 commits that reference this issue on Nov 22, 2025

    chore(docs): add preview docstrings to v3 client (#926)

    54370f5

    fix(bazel): Re-enable Python µgen integration tests post monolith rul…

    751c627

    chore: release 0.50.1 (#928)

    184b557

    feat: use generator for stream results (#926)

    641ae02

    chore: rename rst files to avoid conflict with service names (#926)

    d663f90
  22. parthea
    added 4 commits that reference this issue on Mar 2, 2026

    chore(docs): add preview docstrings to v3 client (#926)

    647a674

    chore(main): release 2.18.0 (#926)

    1fb0b31

    chore(deps): update all dependencies (#926)

    d27d47b

    chore(deps): update all dependencies (#926)

    3a3be0b
  23. parthea
    added a commit that references this issue on Sep 8, 2026

    docs: migrate code from googleapis/python-bigquery (#18303)

    23f9a74
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @theacodes
    theacodes

Labels

api: core

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.