Repository: LMCache/LMCache
File: lmcache/v1/plugin/plugin_launcher.py (Python)

Code before:
                env=env,
                stdout=subprocess.PIPE,
                stderr=subprocess.STDOUT,
                text=True,
            )
            self.plugin_processes.append(proc)
            logger.info(f"Launched plugin: {file} with {interpreter}")

            # Start thread to capture output continuously
            threading.Thread(
                target=self._capture_plugin_output, args=(proc, str(file)), daemon=True
            ).start()
        except Exception as e:
            logger.error(f"Failed to launch plugin {file}: {e}")

    def _get_interpreter(self, file: Path) -> str:
        """Get interpreter from first line comment"""
        interpreters = []
        try:
            with open(file, "r", encoding="utf-8") as f:
                first_line = f.readline().strip()
                if first_line.startswith("#!"):
                    # Extract interpreter path from shebang
                    return first_line[2:].strip()
        except Exception as e:
            logger.error(f"Error reading plugin file {file}: {e}")
            pass

        # Fallback to default interpreters
        if file.suffix == ".py":
            interpreters.append("python")
            interpreters.append("python3")
        elif file.suffix == ".sh":
            interpreters.append("bash")

        # Try each interpreter until we find one that exists
        for interp in interpreters:
            interp = interp.strip()
            resolved_interp = shutil.which(interp)
            if resolved_interp:
                return resolved_interp

        raise ValueError(f"No valid interpreter found for {file} from {interpreters}")

    def _capture_plugin_output(self, proc: subprocess.Popen, plugin_name: str):
        """Continuously capture and log plugin output"""
        try:
            assert proc.stdout is not None, "The plugin subprocess does not have stdout"
            while True:
                line = proc.stdout.readline()
                if not line:

Review comment (suggestion):
Error reading plugin file {file}: {e} --> Error reading interpreter from plugin file {file} - using default interpreters: {e}

Code after:
                env=env,
                stdout=subprocess.PIPE,
                stderr=subprocess.STDOUT,
                text=True,
            )
            self.plugin_processes.append(proc)
            logger.info(f"Launched plugin: {file} with {interpreter}")

            # Start thread to capture output continuously
            threading.Thread(
                target=self._capture_plugin_output, args=(proc, str(file)), daemon=True
            ).start()
        except Exception as e:
            logger.error(f"Failed to launch plugin {file}: {e}")

    def _get_interpreter(self, file: Path) -> str:
        """Get interpreter from first line comment"""
        interpreters = []
        try:
            with open(file, "r", encoding="utf-8") as f:
                first_line = f.readline().strip()
                if first_line.startswith("#!"):
                    # Extract interpreter path from shebang
                    return first_line[2:].strip()
        except Exception as e:
            logger.error(
                f"Error reading interpreter from plugin file {file} - "
                f"using default interpreters: {e}"
            )
            pass

        # Fallback to default interpreters
        if file.suffix == ".py":
            interpreters.append("python")
            interpreters.append("python3")
        elif file.suffix == ".sh":
            interpreters.append("bash")
        else:
            raise ValueError(f"Plugin type {file.suffix} not supported ")

        # Try each interpreter until we find one that exists
        for interpreter in interpreters:
            interpreter = interpreter.strip()
            resolved_interpreter = shutil.which(interpreter)
            if resolved_interpreter:
                return resolved_interpreter

        raise ValueError(f"No valid interpreter found for {file} from {interpreters}")

    def _capture_plugin_output(self, proc: subprocess.Popen, plugin_name: str):
        """Continuously capture and log plugin output"""