-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initialization hook for session creation (#2682)
This adds an initialization hook to customize any botocore sessions. Botocore sessions provide context for creating one or more clients. It allows you to provide configuration, components, hooks, etc. that can be shared across all clients created within that session. There is no similar concept for sessions. Specifically, there is no way to provide a common set of configuration, components, hooks, etc. that can shared across all sessions created within botocore. This change adds this initialization hook. You can now register an initialization callback that's invoked whenever a session is created: ```python import botocore def my_initializer(session: botocore.session.Session) -> None: session.register_component('data_loader', MyNewCrazyLoader()) botocore.register_initializer(my_initializer) ``` Now every session will automatically use this new loader: ```python some_session = botocore.session.get_session() assert isinstance( some_session.get_component('data_loader'), MyNewCrazyLoader ) ```
- Loading branch information
Showing
3 changed files
with
77 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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