如果此問題已被問及之前,請讓我知道在哪裏,對於我的生活,我無法找到任何答案。RDS快照複製的Python進度條
def waitforsnapshot(TargetDBSnapshot):
available = False
while not available:
time.sleep(10)
response_ncali_snap = get_dest_snap(ncali_client, 'testdb', 'manual')
for i in response_ncali_snap:
if i['DBSnapshotIdentifier'] == TargetDBSnapshot:
print("{}: {}...".format(i['DBSnapshotIdentifier'], i['Status']))
if i['Status'] == "available":
available = True
break
我從一個區域移動RDS快照到另一個,和上面的代碼一直工作,直到狀態更改爲「可用」。我試圖添加進度條,而不是每次打印狀態print("{}: {}...".format(i['DBSnapshotIdentifier'], i['Status']))
,直到快照狀態更改爲可用。有沒有辦法使用tqdm或其他庫來做到這一點?
您使用的是EC2還是S3?如果您使用S3Transfer,則可以使用回調獲取進度。 [查看帶有示例進度代碼的文檔](http://boto3.readthedocs.io/en/latest/_modules/boto3/s3/transfer.html)。根據所提供的代碼,我看不到您如何實際傳輸數據。 get_dest_snap返回什麼類型的對象?一個EC2快照對象?如果是這樣,你不能使用[快照進度](http://boto3.readthedocs.io/en/latest/reference/services/ec2.html#EC2.Snapshot.progress)屬性嗎? – agtoever
@agtoever如果我不夠清楚,我很抱歉,我在問題的主題中提到了它 - 這是將RDS快照從一個區域複製到另一個區域時的情況。 get_dest_snap剛剛返回正在複製的區域中存在的快照字典,基本上它是describe_db_snapshots並通過快照創建時間對它們進行排序。 – shabbzy