Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Avoid a KeyError when a ComponentLocator is being called concurrently #2985

Merged
merged 1 commit into from
Jul 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion botocore/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,15 @@ def get_component(self, name):
# Only delete the component from the deferred dict after
# successfully creating the object from the factory as well as
# injecting the instantiated value into the _components dict.
del self._deferred[name]
try:
del self._deferred[name]
except KeyError:
# If we get here, it's likely that get_component was called
# concurrently from multiple threads, and another thread
# already deleted the entry. This means the factory was
# probably called twice, but cleaning up the deferred entry
# should not crash outright.
pass
try:
return self._components[name]
except KeyError:
Expand Down