Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Multiple boto3 clients with a single botocore session is not thread safe #76

Open
smarlowucf opened this issue Nov 12, 2021 · 1 comment

Comments

@smarlowucf
Copy link
Contributor

smarlowucf commented Nov 12, 2021

Whether or not temporary credentials are used with ec2imgutils there's a chance for a session to be shared across multiple clients. This is not recommended based on boto3 documentation https://boto3.amazonaws.com/v1/documentation/api/latest/guide/resources.html?highlight=multithreading#multithreading-or-multiprocessing-with-resources.

This is in reference to the connect method on the EC2ImgUtils class https://github.com/SUSE-Enceladus/ec2imgutils/blob/master/lib/ec2imgutils/ec2imgutils.py#L45.

When using a temporary credential the session gets reused many times with new clients, otherwise the client is created which leaves it up to boto3/botocore to find an existing session or create a new one. As per the boto3 docs it's recommended to explicitly create a new session for every new client.

@smarlowucf
Copy link
Contributor Author

Double checking this, a new session is already created in the default case https://github.com/SUSE-Enceladus/ec2imgutils/blob/master/lib/ec2imgutils/ec2imgutils.py#L59. The only thing to cleanup is to re-use the same client when supplying a session token.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant