Skip to content

Commit

Permalink
Avoid a KeyError when a ComponentLocator is being called concurrently (
Browse files Browse the repository at this point in the history
  • Loading branch information
akx authored Jul 30, 2023
1 parent 4df603d commit 22ca528
Showing 1 changed file with 9 additions and 1 deletion.
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

0 comments on commit 22ca528

Please # to comment.