diff --git a/src/serena/cli.py b/src/serena/cli.py index 6ac341ce..7ee83a1f 100644 --- a/src/serena/cli.py +++ b/src/serena/cli.py @@ -5,6 +5,7 @@ import os import shutil import subprocess import sys +import time from collections.abc import Iterator, Sequence from logging import Logger from pathlib import Path @@ -705,6 +706,7 @@ class ProjectCommands(AutoRegisteringGroup): collected_exceptions: list[Exception] = [] files_failed = [] language_file_counts: dict[Language, int] = collections.defaultdict(lambda: 0) + last_save_time = time.monotonic() for i, f in enumerate(tqdm(files, desc="Indexing")): try: ls = ls_mgr.get_language_server(f) @@ -714,8 +716,10 @@ class ProjectCommands(AutoRegisteringGroup): log.error(f"Failed to index {f}, continuing.") collected_exceptions.append(e) files_failed.append(f) - if (i + 1) % 10 == 0: + now = time.monotonic() + if now - last_save_time >= 30: ls_mgr.save_all_caches() + last_save_time = now reported_language_file_counts = {k.value: v for k, v in language_file_counts.items()} click.echo(f"Indexed files per language: {dict_string(reported_language_file_counts, brackets=None)}") ls_mgr.save_all_caches()