Skip to content

Commit 5ed98ee

Browse files
Catch FileNotFoundError in ConfigManagerActor _read_config method
Becasuse: * not all files in self._config_paths might exists * catching the watchfiles signal and file reading happen in separate async thread and the file could be removed between signal detection and file reading. This prevents unexpected actor crash. Signed-off-by: Elzbieta Kotulska <[email protected]>
1 parent dd7c65f commit 5ed98ee

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/frequenz/sdk/config/_config_managing.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ def _read_config(self) -> abc.Mapping[str, Any]:
130130
except ValueError as err:
131131
_logger.error("%s: Can't read config file, err: %s", self, err)
132132
error_count += 1
133+
except FileNotFoundError:
134+
# It is ok for config file to don't exist.
135+
_logger.info(
136+
"%s: Config file %s not found. Ignoring it.", self, config_path
137+
)
138+
error_count += 1
133139

134140
if error_count == len(self._config_paths):
135141
raise ValueError(f"{self}: Can't read any of the config files")

0 commit comments

Comments
 (0)