我有以下代码,我正在等待方法调用以返回响应。此响应可能需要 10 到 15 秒以上。
我需要在用户等待方法返回响应时显示进度消息。我的 while 条件似乎没有显示进度条。
response = my_api.execute("get some data")
# There is a 10-15 minute delay here...
i = 0
while response is None:
sys.stdout.write('\r')
sys.stdout.write("Fetching MO attribute [%-20s] %d%%" % ('=' * i, 5 * i))
sys.stdout.flush()
sleep(0.25)
i += 1
if response.get_output() != "1 instance(s)":
raise MyError('Could not fetch data. )
for line in response.get_output():
# Do the actual processing
森栏
呼如林
相关分类