115 buf = buf.encode('utf-8', 'backslashreplace') |
118 buf = buf.encode('utf-8', 'backslashreplace') |
116 self.sock.sendall(buf) |
119 self.sock.sendall(buf) |
117 self.nWriteErrors = 0 |
120 self.nWriteErrors = 0 |
118 except OSError: |
121 except OSError: |
119 self.nWriteErrors += 1 |
122 self.nWriteErrors += 1 |
120 if self.nWriteErrors > self.maxtries: |
123 if self.nWriteErrors > AsyncFile.MAX_TRIES: |
121 self.wpending = [] # delete all output |
124 self.wpending = [] # delete all output |
122 self.writeLock.release() |
125 self.writeLock.release() |
123 |
126 |
124 def isatty(self): |
127 def isatty(self): |
125 """ |
128 """ |
193 # The command string is prefixed by a 9 character long length field. |
196 # The command string is prefixed by a 9 character long length field. |
194 length = self.sock.recv(9) |
197 length = self.sock.recv(9) |
195 length = int(length) |
198 length = int(length) |
196 data = b'' |
199 data = b'' |
197 while len(data) < length: |
200 while len(data) < length: |
198 newByte = self.sock.recv(1) |
201 remaining = length - len(data) |
199 data += newByte |
202 newBytes = self.sock.recv(min(remaining, AsyncFile.CMD_BUFSIZE)) |
200 if newByte == b'\n': |
203 data += newBytes |
|
204 if newBytes[-1] == b'\n': |
201 break |
205 break |
202 |
206 |
203 # step 2: convert the data |
207 # step 2: convert the data |
204 return data.decode('utf8', 'backslashreplace') |
208 return data.decode('utf8', 'backslashreplace') |
205 |
209 |
216 @rtype str |
220 @rtype str |
217 """ |
221 """ |
218 self.__checkMode('r') |
222 self.__checkMode('r') |
219 |
223 |
220 if size < 0: |
224 if size < 0: |
221 size = 20000 |
225 size = AsyncFile.BUFSIZE |
222 |
226 |
223 # The integration of the debugger client event loop and the connection |
227 # The integration of the debugger client event loop and the connection |
224 # to the debugger relies on the two lines of the debugger command being |
228 # to the debugger relies on the two lines of the debugger command being |
225 # delivered as two separate events. Therefore we make sure we only |
229 # delivered as two separate events. Therefore we make sure we only |
226 # read a line at a time. |
230 # read a line at a time. |