-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Storage: document thread-safety of client. #5763
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
Storage: document thread-safety of client. #5763
Conversation
Also note general best practice for multiprocessing use. Closes #5685.
| share instances across threads. In multiprocessing scenarious, best | ||
| practice is to create client instances *after* | ||
| :class:`multiprocessing.Pool` or :class:`multiprocessing.Process` invokes | ||
| :func:`os.fork`. |
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.
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.
|
sure
…On Tue, Aug 14, 2018 at 1:04 PM Frank Natividad ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In docs/storage/client.rst
<#5763 (comment)>
:
> @@ -23,6 +23,15 @@ Install the ``google-cloud-storage`` library using ``pip``:
Usage
-----
+.. note::
+
+ Becuase the :class:`~google.cloud.storage.client.Client` uses the
+ third-party :mod:`requests` library by default, it should be safe to
+ share instances across threads. In multiprocessing scenarious, best
+ practice is to create client instances *after*
+ :class:`multiprocessing.Pool` or :class:`multiprocessing.Process` invokes
+ :func:`os.fork`.
Can we update the wording to "is thread-safe" or is that too strong?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#5763 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAPUc2SuZZiCdZP-wSKdfDaZComMg-5sks5uQy1WgaJpZM4VyHbE>
.
|
|
I ran into this same question when trying to optimize some Flask code running on GCF/GAE. Is the library written in such a way where we can make a general statement for all the APIs? Or is it really different for each API? |
|
@kaliberto We have two basic groups of APIs: those which use gRPC as their basic transport, and those whic use requests/HTTP. The gRPC-based clients are threadsafe, but not fork-safe; the requests-based clients are as threadsafe as requests (i.e., no known issues). |
/cc @BrandonY
Also note general best practice for multiprocessing use.
Closes #5685.