In the following code, is the connection to the remote server held open until close()
is called or is it recreated every time read()
is called? In the following code I do see a new network communication happens every time read()
is called, rather than the remote file being buffered as soon as urlopen()
is called.
import urllib2
handle = urllib2.urlopen('http://download.thinkbroadband.com/5MB.zip')
while True:
buff = handle.read(64*1024) # Is a new connection to the server created here?
if len(x) == 0:
break
handle.close()