簡體   English   中英

如何在DynamoDB和Python中重試BatchWrite

[英]How to retry BatchWrites in DynamoDB and Python

我有一個使用Python SDK進行BatchWrite到DynamoDB的功能。

def do_batch_write(write_list)
    while True:
        with table_name.do_batch_write() as batch:
            for write in write_list:
                batch.put_item(write)

            if (all writes passed):
                 break
            else:
                retry unprocessed writes

我知道DDB可能無法執行某些操作,因此您需要檢查未處理的寫入並重試它們,但是我找不到最新的Python SDK的示例,該示例顯示了如何查找未處理的寫入。 有人知道這樣做的正確方法嗎?

您看過文檔嗎? https://boto3.readthedocs.org/en/latest/reference/services/dynamodb.html#DynamoDB.Client.batch_write_item

您將需要從響應中檢查UnprocessedItems,並從響應的外觀中將它們饋入新的batch_write_item中 (即,在未處理項目的同時繼續查看響應,並繼續將它們饋入新的批處理寫入請求中,直到編寫完成為止一切)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM