From 98313840dd8c9281a71a590a19cc96ec4abac46a Mon Sep 17 00:00:00 2001 From: Bjarke Madsen <bjarke@nordu.net> Date: Tue, 20 May 2025 14:18:26 +0200 Subject: [PATCH] don't crash if state file doesn't exist --- brian_polling_manager/configuration.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/brian_polling_manager/configuration.py b/brian_polling_manager/configuration.py index 160b07d..ae43058 100644 --- a/brian_polling_manager/configuration.py +++ b/brian_polling_manager/configuration.py @@ -210,7 +210,12 @@ class State(object): @last.setter def last(self, new_last: Union[float, None]): if not new_last or new_last < 0: - os.unlink(self.cache_filenames['state']) + try: + os.unlink(self.cache_filenames['state']) + except OSError: + logger.exception( + f'unable to delete state file {self.cache_filenames["state"]}') + return else: State._save_json( self.cache_filenames['state'], -- GitLab