Skip to content

Commit

Permalink
Add task timeout warning
Browse files Browse the repository at this point in the history
  • Loading branch information
JBorrow committed Nov 15, 2024
1 parent ce2bfd6 commit c9f0063
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion librarian_background/rolling_deletion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c9f0063

Please sign in to comment.