in ees_network_drive/sync_enterprise_search.py [0:0]
def perform_sync(self):
"""Pull documents from the queue and synchronize it to the Enterprise Search."""
try:
signal_open = True
while signal_open:
documents_to_index = []
while len(documents_to_index) < BATCH_SIZE:
document = self.queue.get()
if document.get("type") == "signal_close":
self.logger.info(f"Found an end signal in the queue. Closing Thread ID {threading.get_ident()}")
signal_open = False
break
else:
documents_to_index.extend(document.get("data"))
# This loop is to ensure if the last document fetched from the queue exceeds the size of
# documents_to_index to more than the permitted chunk size, then we split the documents as per the limit
for document_list in split_documents_into_equal_chunks(documents_to_index, BATCH_SIZE):
self.index_documents(document_list)
except Exception as exception:
self.logger.error(exception)
self.logger.info(f"Thread ID: {threading.get_ident()} Total {self.total_document_indexed} documents \
indexed out of: {self.total_documents_found} till now..")