0

I have a Python script that takes advantage of the latest Vimeo API (https://developer.vimeo.com/api/) to upload some videos to my Vimeo account.

Here is what, in a slightly simplified form, the script basically does:

from vimeo import VimeoClient
vimeo = VimeoClient('my_token_here')
uid = vimeo.upload('/path/to/file.mov')

When file.mov is 3MB or less everything works fine and the file is successfully uploaded. However, for larger files I get a timeout error:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/fabio/.virtualenvs/venv/src/vimeo/vimeo/uploads.py", line 79, in __call__
    return do_upload()
  File "/home/fabio/.virtualenvs/venv/src/vimeo/vimeo/uploads.py", line 70, in do_upload
    self.upload_segment(upload_uri, _range, video_data, filetype or 'mp4')
  File "/home/fabio/.virtualenvs/venv/src/vimeo/vimeo/uploads.py", line 135, in upload_segment
    body=data, headers=request_headers)
  File "/home/fabio/.virtualenvs/venv/lib/python2.7/site-packages/tornado/httpclient.py", line 85, in fetch
    self._async_client.fetch, request, **kwargs))
  File "/home/fabio/.virtualenvs/venv/lib/python2.7/site-packages/tornado/ioloop.py", line 389, in run_sync
    return future_cell[0].result()
  File "/home/fabio/.virtualenvs/venv/lib/python2.7/site-packages/tornado/concurrent.py", line 131, in result
    return super(TracebackFuture, self).result(timeout=timeout)
  File "/home/fabio/.virtualenvs/venv/lib/python2.7/site-packages/tornado/concurrent.py", line 65, in result
    raise self._exception
HTTPError: HTTP 599: Timeout

This is the vimeo library I am using: https://github.com/vimeo/vimeo.py.

And the Tornado library in my virtual environment is updated to the 3.2.1 version.

Any tips for me?

4

1 回答 1

0

Tornado 源HTTPClient,正在使用的默认请求超时为vimeo20 秒。看起来Vimeo 库尝试上传尽可能多的视频,然后查询服务器以查看成功上传了多少。上传视频可能需要超过 20 秒,因此会超时。我不相信他们能正确处理这个问题,因为你从 Tornado 收到超时错误,但他们似乎想要支持不立即上传整个文件。

您可以尝试通过vimeo将本地副本中的链接行更改为以下内容来修改我上面链接的库代码以延长超时时间:

    r = HTTPClient().fetch(upload_uri, method="PUT",
                           body=data, headers=request_headers, 
                           request_timeout=9999.0)

如果这不起作用,您可以尝试在他们的github问题跟踪器上提出问题,并且实际从事该项目的人可能能够进一步帮助您。

于 2014-05-22T16:23:35.877 回答