-
Notifications
You must be signed in to change notification settings - Fork 545
Open
Description
Is there an existing issue for this?
- I have searched the existing issues
What happened?
Description
The file watching service is fragile. If a single unhandled exception occurs during file processing (e.g., a network timeout contacting the backend or a permission error), the entire watching process terminates and does not restart.
How to reproduce
- Start the service
- Modify
watcher_util_handle_file_changes()function inutils/watcher.pyto raise a value errorraise ValueError("For testing") - Trigger a file change in a watched folder.
- Observe that the watcher logs the error and the thread terminates. The service is now effectively dead and receives no further updates.
Root cause
In watcher.py, the entire watchfiles lteration loop is wrapped in a single try...except block
for changes in watch(...):
# ... logic ...
except Exception as e:
logger.error(...)
finally:
logger.info("Watcher stopped")
When an exception is caught, the loop is exited, and the function returns. There is no supervisor loop to restart the worker thread.
Screenshot
Potential fix
- Move the try...except block inside the for loop so that a single bad event doesn't break the loop.
- Implement a supervisor pattern: if the thread dies unexpectedly, restart it.
I would like to work on this issue.
Record
- I agree to follow this project's Code of Conduct
Metadata
Metadata
Assignees
Labels
No labels