Fail all pending requests when process exits
(self)
| 281 | self.on_close() |
| 282 | |
| 283 | def _fail_pending_requests(self): |
| 284 | """Fail all pending requests when process exits""" |
| 285 | # Build error message with stderr output |
| 286 | stderr_output = self.get_stderr_output() |
| 287 | return_code = None |
| 288 | if hasattr(self.process, "poll"): |
| 289 | return_code = self.process.poll() |
| 290 | |
| 291 | if stderr_output: |
| 292 | error_msg = f"CLI process exited with code {return_code}\nstderr: {stderr_output}" |
| 293 | elif return_code is not None: |
| 294 | error_msg = f"CLI process exited with code {return_code}" |
| 295 | else: |
| 296 | error_msg = "CLI process exited unexpectedly" |
| 297 | |
| 298 | # Fail all pending requests |
| 299 | with self._pending_lock: |
| 300 | for request_id, future in list(self.pending_requests.items()): |
| 301 | if not future.done(): |
| 302 | exc = ProcessExitedError(error_msg) |
| 303 | loop = future.get_loop() |
| 304 | loop.call_soon_threadsafe(future.set_exception, exc) |
| 305 | |
| 306 | def _read_exact(self, num_bytes: int) -> bytes: |
| 307 | """ |
no test coverage detected