From 9b372f9d033a9da74b46fb928bddc4e3e253a7ee Mon Sep 17 00:00:00 2001 From: Mackenzie Grimes - NOAA Affiliate Date: Tue, 13 May 2025 17:24:03 -0600 Subject: [PATCH] catch error on file lock release, continue anyway --- .../idsse_common/idsse/common/schema/support_profile.json | 1 + python/idsse_common/idsse/common/utils.py | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/python/idsse_common/idsse/common/schema/support_profile.json b/python/idsse_common/idsse/common/schema/support_profile.json index be6ec637..d289cf44 100644 --- a/python/idsse_common/idsse/common/schema/support_profile.json +++ b/python/idsse_common/idsse/common/schema/support_profile.json @@ -77,6 +77,7 @@ "properties": { "start": { "type": ["string", "null"] }, "duration": { "type": ["number", "null"] }, + "durationInMinutes": { "type": ["number", "null"] }, "rrule": { "type": ["string", "null"] } } }, diff --git a/python/idsse_common/idsse/common/utils.py b/python/idsse_common/idsse/common/utils.py index 90216a60..7a1ca7a4 100644 --- a/python/idsse_common/idsse/common/utils.py +++ b/python/idsse_common/idsse/common/utils.py @@ -161,7 +161,7 @@ def expired(self) -> bool: # Linux (and maybe Windows) don't support birthtime creation_time = os.stat(self._lock_path).st_ctime except FileNotFoundError: - # lock file disappeared since start of function call?? *shrug* treat it as unexpired + # lock file disappeared since start of function call?? Treat it as unexpired creation_time = datetime.now(UTC).timestamp() return (datetime.now(UTC).timestamp() - creation_time) >= self._max_age @@ -198,7 +198,10 @@ def release(self) -> bool: """Release the lock so other processes/threads can do I/O""" if not self.locked: return False - os.remove(self._lock_path) + try: + os.remove(self._lock_path) + except FileNotFoundError: + pass # lock file disappeared since start of function call?? Treat it as released return True def _create_lockfile(self):