In article <[email protected]>, harryos <[email protected]> wrote: > >class DataGrabber(threading.Thread): > def __init__(self,url): > threading.Thread.__init__(self) > self.url=url > def run(self): > data=self.get_page_data() > process_data(data) > > def get_page_data(): > try: > f=urllib.urlopen(self.url) > data=f.read(1024) > except IOError: > #wait for some time and try again > time.sleep(120) > data=self.get_page_data() > return data
Use urllib2 so that you can set a timeout (Python 2.6+). -- Aahz ([email protected]) <*> http://www.pythoncraft.com/ "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." --Red Adair -- http://mail.python.org/mailman/listinfo/python-list
