MCPcopy Index your code
hub / github.com/bugy/script-server / pipe_process_output

Method pipe_process_output

src/execution/process_popen.py:64–104  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

62 self.process.wait()
63
64 def pipe_process_output(self):
65 try:
66 while True:
67 finished = False
68 wait_new_output = False
69
70 if self.is_finished():
71 data = self.process.stdout.read()
72
73 finished = True
74
75 else:
76 data = self.process.stdout.read(1)
77
78 if not data:
79 wait_new_output = True
80
81 if data:
82 output_text = data
83 self._write_script_output(output_text)
84
85 if finished:
86 break
87
88 if wait_new_output:
89 time.sleep(0.01)
90
91 except:
92 self._write_script_output("Unexpected error occurred. Contact the administrator.")
93
94 try:
95 self.kill()
96 except:
97 LOGGER.exception('Failed to kill a process')
98
99 LOGGER.exception('Failed to read script output')
100
101 finally:
102 self.output_stream.close()
103 self.process.stdout.close()
104 self.process.stdin.close()

Callers

nothing calls this directly

Calls 5

readMethod · 0.80
_write_script_outputMethod · 0.80
is_finishedMethod · 0.45
killMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected