2

I am trying to create an automated test using python for testing a youtube API request and response and all of those happening in random quick timely manner. What I have been getting is an unstable HTTP response from the server. I am not using the same object for every connection as I made it in separate methods, but when testing it, I test it all in same method (i.e. call create,edit, and delete consecutively)

Here is the Error that I got.

  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

I was thinking that I should have a time.delay() between each HTTP request?

What do you guys think and suggest me to do on this case, since I am still learning on this matter?

Thank you for all the sugesstion and help ;)

Basic Idea of the Code I am using :

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))

and for testing it I authenticate the user and print user upload a few time after that consecutively

saruberoz
  • 136
  • 1
  • 2
  • 6
  • The error you're getting can have several causes, see http://stackoverflow.com/questions/3231543/python-httplib-responsenotready. Please, provide the actual code. – alecxe May 20 '13 at 20:32
  • The actual HTTP response is actually done on Youtube-API which is why I couldn't provide the actual code. Could you give me a guidance on what causes the HTTPResponseNotReady Error? Thanks :) – saruberoz May 20 '13 at 20:45
  • Could you show what code you are using, how do you use youtube api? It'll be helpful to understand what is really going on. Thanks. – alecxe May 20 '13 at 20:48
  • edited that is basically how I used the youtube api – saruberoz May 20 '13 at 21:04
  • In general, you probably want to avoid making calls to external servers in your unit tests. It causes test instability, makes them slow, and is really impolite (many server hits for fast testing cycles). I'd recommend mocking out the external service in the test of your code. – dbn Aug 19 '13 at 22:09

0 Answers0