Skip to main content

Thread: Python - urllib2 question about .read() and .close()


hi,

have question python hackers.

writing first program (a plugin xbmc) requires use of urllib2. open webpages of interest using
code:
urllib2.urlopen(url).read()
where url string points webpage.

however, seeing other plugins use urllib2 use .close() function @ point. wondering if there reason this.

done avoid memory leaks? seeing memory leaks in xbmc.log , know if closing (using .close()) can getting rid of these memory leaks.

in advance

quote posted kpuz view post
hi,

have question python hackers.

writing first program (a plugin xbmc) requires use of urllib2. open webpages of interest using
code:
urllib2.urlopen(url).read()
where url string points webpage.

however, seeing other plugins use urllib2 use .close() function @ point. wondering if there reason this.

done avoid memory leaks? seeing memory leaks in xbmc.log , know if closing (using .close()) can getting rid of these memory leaks.

in advance
i'm not sure answer question, wanted show alternative method you're using. else can comment on whether method introduces memory leaks or not, i'm not expert in @ all.

code:
    request = urllib2.request(url)      response = urllib2.urlopen(request)      return response.read()
have great day
patrick.

p.s. should note script run once , stop type of script. so, if it's running continuously, there may issues.


Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk Python - urllib2 question about .read() and .close()


Ubuntu

Comments

Popular posts from this blog

Could not place because the source rectangle is empty

Thread: Using smartcard reader with vpnc

Adobe Font Folio 7.0 or just 7?