2

我正在尝试使用python创建一个自动化测试,以测试youtube API请求和响应以及所有这些以随机快速及时的方式发生的事件。我得到的是来自服务器的不稳定的 HTTP 响应。我没有为每个连接使用相同的对象,因为我在单独的方法中创建它,但是在测试它时,我在相同的方法中测试它(即连续调用创建、编辑和删除)

这是我得到的错误。

  File "/var/lib/jenkins/shiningpanda/jobs/2a430f4f/virtualenvs/d41d8cd9/local/lib/python2.7/site-packages/oauth2client/client.py", line 490, in new_request
    redirections, connection_type)
  File "/var/lib/jenkins/shiningpanda/jobs/2a430f4f/virtualenvs/d41d8cd9/local/lib/python2.7/site-packages/httplib2/__init__.py", line 1570, in request
    (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
  File "/var/lib/jenkins/shiningpanda/jobs/2a430f4f/virtualenvs/d41d8cd9/local/lib/python2.7/site-packages/httplib2/__init__.py", line 1317, in _request
    (response, content) = self._conn_request(conn, request_uri, method, body, headers)
  File "/var/lib/jenkins/shiningpanda/jobs/2a430f4f/virtualenvs/d41d8cd9/local/lib/python2.7/site-packages/httplib2/__init__.py", line 1286, in _conn_request
    response = conn.getresponse()
  File "/usr/lib/python2.7/httplib.py", line 1018, in getresponse
    raise ResponseNotReady()
ResponseNotReady

我在想我应该time.delay()在每个 HTTP 请求之间都有一个?

既然我还在学习这件事,你们怎么想并建议我在这个案子上做些什么?

感谢您的所有建议和帮助;)

我正在使用的代码的基本思想:

yt_service = gdata.youtube.service.YouTubeService()    
yt_service.email = 'exampple@gmail.com'    
yt_service.password = 'password'

def GetAndPrintUserUploads(username):    
    yt_service = gdata.youtube.service.YouTubeService()    
    uri = 'http://gdata.youtube.com/feeds/api/users/%s/uploads' % username  
    PrintVideoFeed(yt_service.GetYouTubeVideoFeed(uri))

为了测试它,我验证了用户并在此之后连续打印了几次用户上传

4

0 回答 0