Example #1
0
	def __init__(self, extractorInstance, idList):
		threading.Thread.__init__(self)
		self.extractor = extractorInstance
		self.settings = Settings.getInstance()
		self.store = self.extractor.store
		self.personUpdater = PersonUpdateTool()
		self.idList = idList
Example #2
0
class ProviderThread(threading.Thread):
	'''Provider
	'''
	def __init__(self, extractorInstance, idList):
		threading.Thread.__init__(self)
		self.extractor = extractorInstance
		self.settings = Settings.getInstance()
		self.store = self.extractor.store
		self.personUpdater = PersonUpdateTool()
		self.idList = idList

	def run(self):
		try:
			data_run_out = False
			while not data_run_out:
				if self.idList is None or len(self.idList) == 0:
					walker = PersonWalkThroughOrderByPubcount(self.extractor.generation,
							processer=self.person_processer, fetch_size=100, fix_person_ext=True)
				else:
					walker = PersonWalkThroughByGivenIDList(self.extractor.generation,
							processer=self.person_processer, pids=self.idList, fix_person_ext=True);
				walker.walk()
				
				if self.personUpdater.isAllFinished(self.extractor.generation) or self.settings.byid:
					print "All data finished. Ended Provider."
					data_run_out = True
				print "All person walked, reload all"
				time.sleep(10)

			# reach here if all persons loaded
			self.extractor.waiting_to_finish = True
			print "$mgr/provider:> All person added to Queue, waiting for stop."
		except Exception, e:
			ExceptionHelper.print_exec(e)
			print '-' * 100
			print 'BIG Exception, and can\'t continue.'
			print '-' * 100
			sys.exit()
		finally: