Are the objects created by urllib2.urlopen () a persistent join?

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) # Is a new connection to the server created here?
    if len(x) == 0:
        break
handle.close()
+2
source share
1 answer

Try running wirehark or fiddler and look at port 80, where nothing works. Run your program and see what traffic you get. Must answer your question.

0
source

All Articles