Repository navigation
Conversation
stobrien89
requested changes
Nov 6, 2026
| The ``Session`` that creates a client is not thread safe, so what matters is | ||
| where you call ``session.client()``. Once a client has been created it does not | ||
| call back into its session and can be used from any thread. There are two safe | ||
| patterns: |
Collaborator
There was a problem hiding this comment.
What about lazy initialization behind a lock? That seems like another safe pattern and is the main use case from the linked issue
Comment on lines
+70
to
+73
| ``Session`` objects are not thread safe and should not be shared across | ||
| threads or processes. Clients created from a session are thread safe (with the | ||
| caveats in :ref:`guide_clients_multithreading`), and once a client has been | ||
| created it does not call back into its session. That gives you two safe |
Collaborator
There was a problem hiding this comment.
I don’t think this is always true. clients can still use the session’s loader for paginators/waiters and some credential providers may create clients later during refresh. Could we avoid the “does not call back” guarantee and just say the session doesn’t need to be used directly after client creation?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #, if available:
boto/botocore#2898
Description of changes:
Updates the multithreading sections of the clients and session guide pages to:
session.client()instead ofsession.resource()in the session page example.Testing:
I ran the following commands to build the docs to validate the changes render correctly:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.