Vimeo python 模块超时
Time-out with the Vimeo python module
我在使用 Vimeo API 和最简单的 python 包装器上传语法时遇到严重问题:
v = vimeo.VimeoClient(token, key, secret)
about_me = v.get('/me')
assert about_me.status_code == 200
print(about_me.json())
try:
print("Upload {}...".format(nomFichier))
video_uri = v.upload(fichier)
然后我偶尔会遇到这个错误(但仍然有 90% 的时间):
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='1511923755.cloud.vimeo.com', port=443): Read timed out. (read timeout=1)
这是怎么回事?我在一段时间内 True: loop,它监视一个被监视的文件夹,所以我不知道我是否发出了太多请求,但在操场上我可以看到我仍然有 X-RateLimit-Remaining: 90
所以我不确定发生了什么......
好吧,为了清楚起见,如果您使用的是来自 vimeo 的 python 代码,请注意没有处理上传完成。所以你必须像那样处理异常:
def changeNameOnVimeo(vimeoAcces, URI, name):
success = True
while success:
try:
vimeoAcces.patch(URI, data={'name': '{}'.format(name)})
print("Video renommée sur Viméo.")
success = False
except (ReadTimeout, ConnectTimeout, ConnectionError) as e:
print(e)
time.sleep(5)
print("Video renommée sur Viméo.")
success = False
我不确定 while = True 循环是强制性的,但我喜欢那些。
我在使用 Vimeo API 和最简单的 python 包装器上传语法时遇到严重问题:
v = vimeo.VimeoClient(token, key, secret)
about_me = v.get('/me')
assert about_me.status_code == 200
print(about_me.json())
try:
print("Upload {}...".format(nomFichier))
video_uri = v.upload(fichier)
然后我偶尔会遇到这个错误(但仍然有 90% 的时间):
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='1511923755.cloud.vimeo.com', port=443): Read timed out. (read timeout=1)
这是怎么回事?我在一段时间内 True: loop,它监视一个被监视的文件夹,所以我不知道我是否发出了太多请求,但在操场上我可以看到我仍然有 X-RateLimit-Remaining: 90 所以我不确定发生了什么......
好吧,为了清楚起见,如果您使用的是来自 vimeo 的 python 代码,请注意没有处理上传完成。所以你必须像那样处理异常:
def changeNameOnVimeo(vimeoAcces, URI, name):
success = True
while success:
try:
vimeoAcces.patch(URI, data={'name': '{}'.format(name)})
print("Video renommée sur Viméo.")
success = False
except (ReadTimeout, ConnectTimeout, ConnectionError) as e:
print(e)
time.sleep(5)
print("Video renommée sur Viméo.")
success = False
我不确定 while = True 循环是强制性的,但我喜欢那些。