def _schedule_watches()

in collection_manager/collection_manager/services/CollectionWatcher.py [0:0]


    def _schedule_watches(self):
        for directory, collections in self._collections_by_dir.items():
            granule_event_handler = _GranuleEventHandler(asyncio.get_running_loop(),
                                                         self._granule_updated_callback,
                                                         collections)
            # Note: the Watchdog library does not schedule a new watch
            # if one is already scheduled for the same directory
            try:
                if isinstance(self._observer, S3Observer):
                    self._granule_watches.add(self._observer.schedule(granule_event_handler, directory))
                else:
                    self._granule_watches.add(self._observer.schedule(granule_event_handler, directory, recursive=True))
            except (FileNotFoundError, NotADirectoryError):
                bad_collection_names = ' and '.join([col.dataset_id for col in collections])
                logger.error(f"Granule directory {directory} does not exist. Ignoring {bad_collection_names}.")