views:

253

answers:

1

I am making several http requests to a particular host using python's urllib2 library. Each time a request is made a new tcp and http connection is created which takes a noticeable amount of time. Is there any way to keep the tcp/http connection alive using urllib2?

+1  A: 

urlgrabber supports keepalive.

Ignacio Vazquez-Abrams
http://stackoverflow.com/questions/1037406/python-urllib2-with-keep-alive
Mirko Nasato
This seems to work, but urlgrabber's keepalive does not really work with python 2.6. I think I fixed it by modifying keepalive.py. Here is the diff:163< class HTTPResponse(httplib.HTTPResponse):---> class HTTPResponse(urllib2.addinfourl):
speedplane