def start_producer()

in ees_microsoft_outlook/deletion_sync_command.py [0:0]


    def start_producer(self, queue):
        """This method starts async calls for the producer which is responsible
        for fetching documents from the Microsoft Outlook and pushing them in the shared queue
        :param queue: Shared queue to store the fetched documents
        """
        thread_count = self.config.get_value("microsoft_outlook_sync_thread_count")
        product_type = self.config.get_value("connector_platform_type")
        self.logger.debug(f"Starting producer for fetching objects from {product_type}")

        # Logic to fetch users from Microsoft Exchange or Office365
        if constant.CONNECTOR_TYPE_OFFICE365 in self.config.get_value(
            "connector_platform_type"
        ):
            office365_connection = Office365User(self.config)
            users = office365_connection.get_users()
            users_accounts = office365_connection.get_users_accounts(users)
        elif constant.CONNECTOR_TYPE_MICROSOFT_EXCHANGE in self.config.get_value(
            "connector_platform_type"
        ):
            microsoft_exchange_server_connection = MicrosoftExchangeServerUser(
                self.config
            )
            users = microsoft_exchange_server_connection.get_users()
            users_accounts = microsoft_exchange_server_connection.get_users_accounts(
                users
            )

        if len(users_accounts) >= 0:
            self.logger.info(
                f"Successfully fetched users accounts from the {product_type}"
            )
        else:
            self.logger.info("Error while fetching users from the Active Directory")
            exit()

        start_time, end_time = (
            self.config.get_value("start_time"),
            constant.CURRENT_TIME,
        )
        # Logic to fetch mails, calendars, contacts and task from Microsoft Outlook by using multithreading approach
        time_range_list = self.get_datetime_iterable_list(start_time, end_time)
        self.create_jobs_for_mails_deletion(
            thread_count,
            users_accounts,
            time_range_list,
            queue,
        )
        self.create_jobs_for_calendar_deletion(
            thread_count,
            users_accounts,
            time_range_list,
            queue,
        )
        self.create_jobs_for_contacts_deletion(
            thread_count,
            users_accounts,
            time_range_list,
            queue,
        )
        self.create_jobs_for_tasks_deletion(
            thread_count,
            users_accounts,
            time_range_list,
            queue,
        )
        for _ in range(self.config.get_value("enterprise_search_sync_thread_count")):
            queue.end_signal()