Skip to content

Added a defer_refresh parameter to AutoRefreshableSession!

Compare
Choose a tag to compare
@michaelthomasletts michaelthomasletts released this 19 Feb 06:38
· 464 commits to main since this release

Someone recently asked me in a thread on Reddit about the difference between the RefreshableCredentials and DeferredRefreshableCredentials objects in botocore. That question got me thinking that I should finally add a defer_refresh option to AutoRefreshableSession so that users can choose between lazy and active temporary credential refreshes, which is something I planned on doing eventually but had not prioritized yet.

For context, the DeferredRefreshableCredentials object does not refresh temporary credentials until those credentials are explicitly needed; however, the RefreshableCredentials object refreshes temporary credentials the moment that they expire. The former is lazy; the latter is active. It is possible that the latter might be inefficient in some systems, hence my decision to finally include defer_refresh as a parameter.

Please note that, according to one user, DeferredRefreshableCredentials is leaking memory. I have not tested that claim myself; however, it may, according to their analysis, be something to be mindful of. You may, therefore, want to use defer_refresh=False in the meantime until that issue is resolved. I will monitor the issue and update the version of boto3 in pyproject.toml accordingly.