def __get_iteration_list(self, max_count):
			attempts = 0
			got_items_indexes =[]
			while attempts < (10  if self.index else 4) and len(got_items_indexes) < max_count:
				attempts += 1
				if self.index>=10: 
					remaining = max_count -len(self.list_of_items);
				else:
					remaining = 1

				try:
					got_items_indexes += self.__get_iteration_block(remaining)
					
					if not got_items_indexes:
						if self.index > 200:
							self.index = 10 + random.randint(0,200)
						else: 
							self.index = 0
						continue
					
				except BaseException , err:
					raise
					if got_items_indexes:
						try:
							ScannerQueue.objects.filter(id__in = got_items_indexes).update(state=ScannerQueue.SCANQ_IDLE)
						except:
							pass

					raise err

			return got_items_indexes
Grab a block of scan task items
dataset/ETHPy150Open operasoftware/tlsprober/probedb/scanner/models.py/ScannerQueue.Queue.__get_iteration_list