def local(uids=[]): fetcher = CnFetcher() fetcher.login() connection_error = False while len(uids) > 0 or connection_error: if not connection_error: uid = uids.pop() try: crawler = UserCrawler(uid, fetcher) crawler.run() connection_error = False except URLError, e: logger.exception(e) connection_error = True time.sleep(10)