Skip to content

Commit f22a5c0

Browse files
committed
Add clarification about watching the parent directory
Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 36ecb42 commit f22a5c0

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/frequenz/sdk/actor/_config_managing.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ def __init__(
4949
if isinstance(config_path, pathlib.Path)
5050
else pathlib.Path(config_path)
5151
)
52+
# FileWatcher can't watch for non-existing files, so we need to watch for the
53+
# parent directory instead just in case a configuration file doesn't exist yet
54+
# or it is deleted and recreated again.
5255
self._file_watcher: FileWatcher = FileWatcher(
5356
paths=[self._config_path.parent], event_types=event_types
5457
)
@@ -82,6 +85,8 @@ async def run(self) -> None:
8285

8386
async for event in self._file_watcher:
8487
if event.type != FileWatcher.EventType.DELETE:
88+
# Since we are watching the whole parent directory, we need to make sure
89+
# we only react to events related to the configuration file.
8590
if event.path == self._config_path:
8691
_logger.info(
8792
"%s: Update configs, because file %s was modified.",

0 commit comments

Comments
 (0)