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
where url string points webpage.code:urllib2.urlopen(url).read()
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.
have great daycode:request = urllib2.request(url) response = urllib2.urlopen(request) return response.read()
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
Post a Comment