Nomad14
Nomad14

Reputation: 33

Is boto3 Client taken from a Resource thread-safe? Client: `boto3.resource('dynamodb').meta.client`

I am using batch_execute_statement to update the data in dynamodb in AWS Lambda. To do so, I am getting the boto3 client from a resource like this:

boto3.resource('dynamodb').meta.client.batch_execute_statement(Statements=statements)

As batch_execute_statement has a limitation to take 25 statements at a time, I want to use multi-treading to make this faster.

[What I have tried]

[QUE]

I followed these references:

Upvotes: 3

Views: 825

Answers (1)

Leeroy Hannigan
Leeroy Hannigan

Reputation: 19893

DynamoDB boto3 resource client is not thread safe. You should create a new client for each process.

DynamoDB does not provide an official way to do BatchUpdate. I would suggest to use the UpdateItem API and perhaps an async client, such as boto3aio

Upvotes: 1

Related Questions