Is boto3 low level client for S3 thread-safe? Documentation is not explicit about it.
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#client
A similar issue is discussed in Github
https://github.com/boto/botocore/issues/1246
But still there is no answer from maintainers.
From documentation:
Instantiation of the client is not thread safe while an instance is. To make things work in a multi-threaded environment, put instantiation in a global Lock like this:
If you take a look at the Multithreading/Processing documentation for boto3 you can see that they recommend one client per session as there is shared data between instance that can be mutated by individual threads.
It also looks like there's an open github issue for this exact question. https://github.com/boto/botocore/issues/1246
I recently tried using the single boto client instance using
concurrent.futures.ThreadPoolExecutor
. I run into exceptions coming from boto. I assume the boto client is not thread safe in this case.The exception I got