Skip to content

Commit e0e16e2

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

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

examples/live_updates/main.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,14 @@ def main():
4949
print("Live updater started. Watching for changes in the 'data' directory.")
5050
print("Try adding, modifying, or deleting files in the 'data' directory.")
5151
print("Press Ctrl+C to stop.")
52-
updater.wait()
52+
try:
53+
while True:
54+
updates = updater.next_status_updates()
55+
if not updates.active_sources:
56+
print("No more active sources. Stopping live updater...")
57+
break
58+
except KeyboardInterrupt:
59+
print("Stopping live updater...")
5360

5461

5562
if __name__ == "__main__":

0 commit comments

Comments
 (0)