I don't get why sys.exit(1) doesn't exit the while loop in the follow case
vontio at gmail.com
Tue Oct 5 05:13:53 CEST 2010
Try to use sys.exit(0)
Maybe you should print out the error in your except block.
2010/10/5, chad <cdalten at gmail.com>:
> Given the following..
> import urllib2
> import sys
> import time
> while 1:
> con = urllib2.urlopen("http://www.google.com")
> data = con.read()
> print "connected"
> #The loop doesn't exit if I use sys.exit(1)
> If I would replace 'break' with 'sys.exit(1)', the while loop will
> keep printing connected every 2 seconds? Why I this? I thought exit
> meant exit.
More information about the Python-list