Skip to content

Commit facbe04

Browse files
committed
fix: improve live updater control flow with error handling
1 parent 4265077 commit facbe04

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

examples/live_updates/main.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
1-
import dataclasses
21
import datetime
32

43
import cocoindex
54
from dotenv import load_dotenv
65

76

8-
@dataclasses.dataclass
9-
class Document:
10-
filename: str
11-
content: str
12-
13-
147
@cocoindex.flow_def(name="LiveUpdates")
158
def live_update_flow(
169
flow_builder: cocoindex.FlowBuilder, data_scope: cocoindex.DataScope
@@ -49,7 +42,10 @@ def main():
4942
print("Live updater started. Watching for changes in the 'data' directory.")
5043
print("Try adding, modifying, or deleting files in the 'data' directory.")
5144
print("Press Ctrl+C to stop.")
52-
updater.wait()
45+
try:
46+
updater.wait()
47+
except KeyboardInterrupt:
48+
print("Stopping live updater...")
5349

5450

5551
if __name__ == "__main__":

0 commit comments

Comments
 (0)