In the following code, is it connected to the remote server open until it is called close()or is it recreated every time it is called read()? In the following code, I see that a new network communication occurs every time a read()remote file is called , but not deleted, as soon as it is called urlopen().
import urllib2
handle = urllib2.urlopen('http://download.thinkbroadband.com/5MB.zip')
while True:
buff = handle.read(64*1024)
if len(x) == 0:
break
handle.close()
source
share