Well I need a bit of help I have come to find out after bring down our system that apparently the python library for urllib2 is buggy as all get out. Apparently they can’t figure out how to fix it so it doesn’t keep locking connections and never closes them.
So with that said does anyone know how I can make an authenticated connection to url in a script?
The following works but over time will stop working because the connections don’t get closed. From everything I have found this appears to be know error but no real work around that works.
import sys, system
username = ‘usr’
password = ‘pwd’
auth_handler = urllib2.HTTPPasswordMgrWithDefaultRealm()
handler = urllib2.HTTPBasicAuthHandler(auth_handler)
opener = urllib2.build_opener(handler)
import xml.etree.ElementTree as ET
mytree = ET.parse(response)
for elem in mytree.findall(‘var’):
value = elem.find(‘val’).text
tagName = elem.attrib.get(‘id’)