From dc6998c771e17c4d53a5232ba5b1d08d1eb05d3f Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Tue, 7 Aug 2018 09:00:56 -0400 Subject: [PATCH 1/2] Document thread-safety of storage client. Also note general best practice for multiprocessing use. Closes #5685. --- docs/storage/client.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/storage/client.rst b/docs/storage/client.rst index 00a02951fad2..ef892072277a 100644 --- a/docs/storage/client.rst +++ b/docs/storage/client.rst @@ -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`. + .. automodule:: google.cloud.storage.client :members: :show-inheritance: From 23546d2d9c6bba7baaa047bcece39dedc543ba31 Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Mon, 20 Aug 2018 12:00:36 -0400 Subject: [PATCH 2/2] Strengthen language for thread safety. [ci skip] --- docs/storage/client.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/storage/client.rst b/docs/storage/client.rst index ef892072277a..0e52689a87bc 100644 --- a/docs/storage/client.rst +++ b/docs/storage/client.rst @@ -26,7 +26,7 @@ Usage .. note:: Becuase the :class:`~google.cloud.storage.client.Client` uses the - third-party :mod:`requests` library by default, it should be safe to + third-party :mod:`requests` library by default, it is 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