From: Phonethics Mobile Media on 19 Apr 2010 08:44 handler = urllib2.urlopen(req) is taking way too much time to retrieve the URL. The same code using sockets in PHP doesn't delay this long. I had 'Authorization':'Basic ' + base64.b64encode("username:password") in my header though. [ I didnt use HTTPPasswordMgr & HTTPPasswordMgrWithDefaultRealm because I was unable to send headers with the example shown here : http://docs.python.org/howto/urllib2.html#id6 ] I have data = handler.readline() in a loop - this is an endless network script (twitter streaming) so cant really wait for the entire url contents to finish loading. I had to socket.setdefaulttimeout to 30 to make it work. Is it because python is getting chunks in high number of KBs ? Python 2.6.2 -- Phonethics
|
Pages: 1 Prev: [pylint] why pylint wants only capitals identifiers? Next: Python DXF import library? |