MCPcopy Create free account
hub / github.com/microsoft/debugpy / _process_chunk

Method _process_chunk

src/debugpy/launcher/output.py:76–106  ·  view source on GitHub ↗
(self, s, final=False)

Source from the content-addressed store, hash-verified

74 self._process_chunk(b"", final=True)
75
76 def _process_chunk(self, s, final=False):
77 s = self._decoder.decode(s, final=final)
78 if len(s) == 0:
79 return
80
81 try:
82 launcher.channel.send_event(
83 "output", {"category": self.category, "output": s.replace("\r\n", "\n")}
84 )
85 except Exception:
86 pass # channel to adapter is already closed
87
88 if self._stream is None:
89 return
90
91 try:
92 s, _ = self._encode(s, "surrogateescape")
93 size = len(s)
94 i = 0
95 while i < size:
96 written = self._stream.write(s[i:])
97 self._stream.flush()
98 if written == 0:
99 # This means that the output stream was closed from the other end.
100 # Do the same to the debuggee, so that it knows as well.
101 os.close(self._fd)
102 self._fd = None
103 break
104 i += written
105 except Exception:
106 log.swallow_exception("Error printing {0!r} to {1}", s, self.category)
107
108
109def wait_for_remaining_output():

Callers 1

_workerMethod · 0.95

Calls 5

send_eventMethod · 0.80
decodeMethod · 0.45
writeMethod · 0.45
flushMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected