Start watch mode in a background thread. Returns the started thread, or None if watchdog is unavailable.
(
repo_root: Path,
store: GraphStore,
daemon: bool = True,
)
| 1209 | |
| 1210 | |
| 1211 | def start_watch_thread( |
| 1212 | repo_root: Path, |
| 1213 | store: GraphStore, |
| 1214 | daemon: bool = True, |
| 1215 | ) -> threading.Thread | None: |
| 1216 | """Start watch mode in a background thread. |
| 1217 | |
| 1218 | Returns the started thread, or None if watchdog is unavailable. |
| 1219 | """ |
| 1220 | try: |
| 1221 | import watchdog # noqa: F401 |
| 1222 | except ImportError: |
| 1223 | logger.warning("watchdog not installed; auto-watch disabled") |
| 1224 | return None |
| 1225 | |
| 1226 | thread = threading.Thread( |
| 1227 | target=watch, |
| 1228 | args=(repo_root, store), |
| 1229 | daemon=daemon, |
| 1230 | name="crg-watch", |
| 1231 | ) |
| 1232 | thread.start() |
| 1233 | logger.info("Auto-watch started for %s", repo_root) |
| 1234 | return thread |