AOSSIE-Org / AOSSIE-Org/PictoPy

BUG: Sync-service: Watcher Service Permanently Dies on Unhandled Exception

Đang mở
#1,032 3 bình luận 0 reaction 1 người được giao Được @DeveloperAmrit nhận Xem trên GitHub
backend bug
Ngôn ngữ chính
Python
Star
283
Fork
679
Merge trung bình
7 ngày 2 giờ
Pull request đã merge (30 ngày)
3

Mô tả

### Is there an existing issue for this?

- [x] 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
1. Start the service
2. Modify `watcher_util_handle_file_changes()` function in `utils/watcher.py` to raise a value error `raise ValueError("For testing")`
3. Trigger a file change in a watched folder.
4. 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
```try:
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
Image

### Potential fix
1. Move the try...except block inside the for loop so that a single bad event doesn't break the loop.
2. Implement a supervisor pattern: if the thread dies unexpectedly, restart it.

I would like to work on this issue.

### Record

- [x] I agree to follow this project's Code of Conduct

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.