- def __exit__(self, type, value, traceback):
+ def __exit__(self, _, value, traceback) -> Literal[False]:
+ if self.locktime:
+ ts = datetime.datetime.now().timestamp()
+ duration = ts - self.locktime
+ if duration >= config.config['lockfile_held_duration_warning_threshold_sec']:
+ # Note: describe duration briefly only does 1s granularity...
+ str_duration = datetime_utils.describe_duration_briefly(int(duration))
+ msg = f'Held {self.lockfile} for {str_duration}'
+ logger.warning(msg)
+ warnings.warn(msg, stacklevel=2)