Complete the code to specify the maximum number of items allowed in a single batch write request.
max_items = [1]The maximum number of items allowed in a single DynamoDB batch write request is 25.
Complete the code to retry unprocessed items after a batch write operation.
if response.get('UnprocessedItems'): retry_items = response['[1]']
UnprocessedItems contains the items that DynamoDB did not process in the batch write and need to be retried.
Fix the error in the code to correctly handle batch write retries with exponential backoff.
import time retry_count = 0 while retry_count < 5: response = client.batch_write_item(RequestItems=batch) unprocessed = response.get('UnprocessedItems') if not unprocessed: break batch = unprocessed time.sleep([1]) retry_count += 1
Using exponential backoff with 2 ** retry_count seconds helps avoid throttling by increasing wait time after each retry.
Fill both blanks to create a batch write request with a limit and handle unprocessed items.
batch_items = items[:[1]] response = client.batch_write_item(RequestItems=[2])
The batch write limit is 25 items, and the request must be a dictionary with the table name as the key.
Fill all three blanks to implement a retry loop with batch write, exponential backoff, and unprocessed items handling.
max_retries = [1] retry = 0 while retry < max_retries: response = client.batch_write_item(RequestItems=[2]) unprocessed = response.get('UnprocessedItems') if not unprocessed: break [3](2 ** retry) retry += 1
Set max retries to 5, pass the batch dictionary with table name, and use time.sleep for exponential backoff.