in source/client/python/api-v0.1/api/state_table_dynamodb.py [0:0]
def batch_write(self, entries=[]):
"""
Function writes batch of rows into DynamoDB table
Args:
entries - rows to write into table
Returns:
Nothing
Throws:
StateTableException - on throttling
Exception - for any other unexpected exception
"""
tasks_batches = [entries[x:x + self.MAX_WRITE_BATCHS_SIZE] for x in range(0, len(entries), self.MAX_WRITE_BATCHS_SIZE)]
for ddb_batch in tasks_batches:
with self.state_table.batch_writer() as batch: # batch_writer is flushed when exiting this block
for entry in ddb_batch:
try:
batch.put_item(Item=entry)
except ClientError as e:
if e.response['Error']['Code'] in ["ThrottlingException", "ProvisionedThroughputExceededException"]:
msg = f"DynamoDB Batch Write Failed from DynamoDB, Throttling Exception [{e}] [{traceback.format_exc()}]"
logging.warning(msg)
raise StateTableException(e, msg, caused_by_throttling=True)
else:
msg = f"DynamoDB Batch Write Failed from DynamoDB Exception [{e}] [{traceback.format_exc()}]"
logging.error(msg)
raise Exception(e)
except Exception as e:
msg = f"DynamoDB Batch Write Failed from DynamoDB Exception [{e}] [{traceback.format_exc()}]"
logging.error(msg)
raise Exception(e)