如何使用 boto3 等待 dynamodb 更新表或 ACTIVE 状态 [英] How can I wait for a dynamodb update table or ACTIVE state using boto3

查看:45
本文介绍了如何使用 boto3 等待 dynamodb 更新表或 ACTIVE 状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在更改表格,例如使用 boto3 的容量设置然后我需要等待它的完成

I am changing the table, for example the capacity settings using boto3 then I need to wait for its completation

我更喜欢使用 boto3.resource('dynamodb').Table('MyTable') 而不是 dynamodb 客户端的解决方案.

I would prefer a solution using boto3.resource('dynamodb').Table('MyTable') instead of dynamodb client.

推荐答案

试试这个让你的程序等到表格更新完成:

Try this to make your program wait until the Table Update is finished:

def table_status_checker(self):
    while True:
        table = self.__dynamodb.Table('table_name')
        response = table.meta.client.describe_table(
            TableName='table_name'
        )
        print(response['Table']['TableStatus'])
        if response['Table']['TableStatus'] == 'ACTIVE':
            break

控制台 UI 和这个 describe_table(...) 之间存在很小的滞后.
因此,不要与控制台 UI 表状态混淆.

There is small lag between Console UI and this describe_table(...).
Therefore, don't get confused with the Console UI Table Status.

这篇关于如何使用 boto3 等待 dynamodb 更新表或 ACTIVE 状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆