Skip to content

Commit

Permalink
Merge pull request #5431 from not522/fix-heartbeat
Browse files Browse the repository at this point in the history
Fix heartbeat for race condition
  • Loading branch information
nabenabe0928 committed May 8, 2024
2 parents 8762a2f + 905ccd7 commit ab958d4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion optuna/storages/_rdb/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from contextlib import contextmanager
import copy
from datetime import datetime
from datetime import timedelta
import json
import logging
import os
Expand Down Expand Up @@ -1010,7 +1011,7 @@ def _get_stale_trial_ids(self, study_id: int) -> List[int]:
continue
assert len(trial.heartbeats) == 1
heartbeat = trial.heartbeats[0].heartbeat
if (current_heartbeat - heartbeat).seconds > grace_period:
if current_heartbeat - heartbeat > timedelta(seconds=grace_period):
stale_trial_ids.append(trial.trial_id)

return stale_trial_ids
Expand Down

0 comments on commit ab958d4

Please sign in to comment.