Boto3 client error in multi threaded environment.
See original GitHub issueI am using uwsgi behind django in production with threads enabled. I occasionally get
KeyError
'endpoint_resolver'
from this line django_s3_storage/storage.py in _setup at line 140
if self.settings.AWS_S3_ENDPOINT_URL:
connection_kwargs["endpoint_url"] = self.settings.AWS_S3_ENDPOINT_URL
self.s3_connection = boto3.client("s3", config=Config(
s3={"addressing_style": self.settings.AWS_S3_ADDRESSING_STYLE},
signature_version=self.settings.AWS_S3_SIGNATURE_VERSION,
), **connection_kwargs)
def _setting_changed_received(self, setting, **kwargs):
if setting.startswith("AWS_"):
# HACK: No supported way to close the HTTP session from boto3... :S
self.s3_connection._endpoint.http_session.close()
upon searching I got this from boto3 documentation. Is it possible to do the same? like django-storages
does here.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Is boto3 client thread-safe - python - Stack Overflow
Instantiation of the client is not thread safe while an instance is. To make things work in a multi-threaded environment, put instantiation ...
Read more >boto3.client function is not thread-safe. It can fail when called ...
Describe the bug Th function boto3.client can fail when called from multiple threads Steps to reproduce import concurrent.futures import ...
Read more >Error handling — Boto3 Docs 1.26.35 documentation
Any Boto3 clients you create will use these same statically defined exception classes. The most common botocore exception you'll encounter is ClientError ....
Read more >boto3: How to Use Any AWS Service with Python - Dashbird
boto3, aws-cli, and botocore based on S3 as an example ... resources are not thread-safe, so if you plan to use multithreading or ......
Read more >Handling Errors in Boto3 & Botocore - Trek10
Your boto3 client also carries its own exception factory - you can build an exception class from any error code from those docs...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve made your suggested fix to the master branch. Please let me know if it works. 😃
As a general comment on the boto3 library though - what total twaddle is this?! (I know it’s not your library, but I’m venting). Sure… making the client not thread-safe, I understand that not everything should be thread-safe. But If I explicitly create a new client in a new thread, why make it implicitly share a non-thread-safe data structure?! That’s the worst of all worlds!
The boto3 library has been a pain to transition to. All the return values are untyped dicts. The documentation is all over the place. I don’t see how it can be remotely considered an upgrade from boto2. The only reason to transition to is was that the boto2 support was being dropped.
On 10 January 2018 at 10:18, Noorhteen Raja J notifications@github.com wrote:
0.12.3 is now released. Thanks for confirming the fix!
On 11 January 2018 at 10:46, Noorhteen Raja J notifications@github.com wrote: