Skip to content

Commit e0cacce

Browse files
Add a note to the FileWatcher documentation
To clarify the responsibility of the owner of the FileWatcher instance. Signed-off-by: Daniel Zullo <[email protected]>
1 parent acefe46 commit e0cacce

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/frequenz/channels/file_watcher.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ class FileWatcher(Receiver[Event]):
7070
the [`path`][frequenz.channels.file_watcher.Event.path] where the change was
7171
observed.
7272
73+
Note:
74+
The owner of the [`FileWatcher`][frequenz.channels.file_watcher.FileWatcher]
75+
receiver is responsible for recreating the `FileWatcher` after it has been
76+
cancelled or stopped.
77+
For example, if a [`Task`][asyncio.Task] uses an asynchronous iterator to consume
78+
events from the `FileWatcher` and the task is cancelled, the `FileWatcher` will
79+
also stop. Therefore, the same `FileWatcher` instance cannot be reused for a new
80+
task to consume events. In this case, a new FileWatcher instance must be created.
81+
7382
# Event Types
7483
7584
The following event types are available:

0 commit comments

Comments
 (0)