diff --git a/librarian_background/rolling_deletion.py b/librarian_background/rolling_deletion.py index 46ed70d..4a7a4e7 100644 --- a/librarian_background/rolling_deletion.py +++ b/librarian_background/rolling_deletion.py @@ -95,7 +95,16 @@ def core(self, session: Session): deleted = 0 for instance in instances: - # TODO: Soft timeout + # First, see if we've timed out. + if datetime.datetime.now(timezone.utc) - core_begin > self.soft_timeout: + logger.warning( + "Ran out of time in deletion task! Only successfully deleted " + "{n}/{m} instances; we will return later", + n=deleted, + m=len(instances), + ) + return False + # Check that we got what we wanted. try: assert instance.created_time.replace(tzinfo=timezone.utc) < age_cutoff