MCPcopy
hub / github.com/tirth8205/code-review-graph / _start_watcher

Method _start_watcher

code_review_graph/daemon.py:921–963  ·  view source on GitHub ↗

Spawn a child process running ``code-review-graph watch`` for *repo*.

(self, repo: WatchRepo)

Source from the content-addressed store, hash-verified

919 pass
920
921 def _start_watcher(self, repo: WatchRepo) -> None:
922 """Spawn a child process running ``code-review-graph watch`` for *repo*."""
923 self._config.log_dir.mkdir(parents=True, exist_ok=True)
924 log_path = self._config.log_dir / f"{repo.alias}.log"
925
926 crg_bin = shutil.which("code-review-graph")
927 if crg_bin:
928 cmd: list[str] = [crg_bin, "watch", "--repo", repo.path]
929 else:
930 cmd = [
931 sys.executable,
932 "-m",
933 "code_review_graph",
934 "watch",
935 "--repo",
936 repo.path,
937 ]
938
939 log_fd = open(log_path, "ab") # noqa: SIM115
940 try:
941 proc = subprocess.Popen(
942 cmd,
943 cwd=repo.path,
944 stdout=log_fd,
945 stderr=subprocess.STDOUT,
946 stdin=subprocess.DEVNULL,
947 )
948 except Exception:
949 log_fd.close()
950 logger.exception("Failed to start watcher for '%s'", repo.alias)
951 return
952
953 # The log fd is inherited by the child; we can close our copy.
954 # The child keeps the fd open via its own reference.
955 log_fd.close()
956
957 self._children[repo.alias] = proc
958 logger.info(
959 "Started watcher for '%s' (PID %d) — log: %s",
960 repo.alias,
961 proc.pid,
962 log_path,
963 )
964
965 @staticmethod
966 def _terminate_child(alias: str, proc: subprocess.Popen[bytes]) -> None:

Callers 3

startMethod · 0.95
reconcileMethod · 0.95
_check_healthMethod · 0.95

Calls 1

closeMethod · 0.45

Tested by

no test coverage detected