# image_import_loop.py import time from app import create_app from app.utils.image_importer import import_images_task app = create_app() def looped_import(source_dir='/import', dest_dir='/images', delay_seconds=7200): with app.app_context(): print("[Image Importer] Starting import task...") try: result = import_images_task(source_dir, dest_dir) print(f"[Image Importer] {result}") except Exception as e: print(f"[Image Importer] Error: {e}") print(f"[Image Importer] Sleeping for {delay_seconds / 3600:.1f} hours...\n") time.sleep(delay_seconds) if __name__ == '__main__': looped_import()