Skip to content

Commit

Permalink
raise when cleaner crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
malmans2 committed Mar 22, 2024
1 parent 32d1b58 commit 7910621
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions cads_worker/entry_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,18 @@


def _cache_cleaner() -> None:
max_size = int(os.environ.get("MAX_SIZE", 1_000_000_000))
cache_bucket = os.environ.get("CACHE_BUCKET", None)
max_size = int(os.environ.get("MAX_SIZE", 1_000_000_000))
method = os.environ.get("METHOD", "LRU")
delete_unknown_files = bool(os.environ.get("DELETE_UNKNOWN_FILES", 1))
lock_validity_period = float(os.environ.get("LOCK_VALIDITY_PERIOD", 60 * 60 * 24))
LOGGER.info("Running cache cleaner", max_size=max_size, cache_bucket=cache_bucket)
try:
cacholote.clean_cache_files(
maxsize=max_size,
method=os.environ.get("METHOD", "LRU"), # type: ignore[arg-type] # let cacholote handle it
delete_unknown_files=bool(os.environ.get("DELETE_UNKNOWN_FILES", 1)),
lock_validity_period=float(
os.environ.get("LOCK_VALIDITY_PERIOD", 60 * 60 * 24)
),
)
except Exception:
LOGGER.exception("cache_cleaner crashed")
cacholote.clean_cache_files(
maxsize=max_size,
method=method,
delete_unknown_files=delete_unknown_files,
lock_validity_period=lock_validity_period,
)


def cache_cleaner() -> None:
Expand Down

0 comments on commit 7910621

Please sign in to comment.