def prepare_for_inactivity(self):
        """Can be called before times when this iterator instance will not be used for some period of
        time.

        This is necessary to do on some platforms, such as Windows, where open file handles should be closed
        while no real work is going on.

        No calls are necessary to bring it out of this mode.  The next invocation of any method on this
        instance will result in the instance no longer being considered inactive.
        """
        # This is a pain, but Windows does not allow for anyone to delete a file or its parent directory while
        # someone has a file handle open to it.  So, to be nice, we should close ours.  However, it does limit
        # our ability to detect and more easily handle log rotates.  (Ok, it is not completely true that Windows does
        # not allow for file deletes while someone has a file handle open, but you have to use the native win32 api
        # to be able to open files that work in such a way.. and it still does not allow for the parent dirs to be
        # deleted.)
        close_file = (sys.platform == 'win32')

        # also close any files that haven't been modified for a certain amount of time.
        # This can help prevent errors from having too many open files if we are scanning
        # a directory with many files in it.
        if self.__max_modification_duration:
            try:
                current_datetime = datetime.datetime.now()
                delta = current_datetime - self.__modification_time
                total_micros = delta.microseconds + (delta.seconds + delta.days * 24 * 3600) * 10**6
                if total_micros > self.__max_modification_duration * 10**6:
                    close_file = True

            except __HOLE__:
                pass

        if close_file:
            for pending in self.__pending_files:
                self.__close_file(pending)
dataset/ETHPy150Open scalyr/scalyr-agent-2/scalyr_agent/log_processing.py/LogFileIterator.prepare_for_inactivity