eric6/DebugClients/Python/AsyncFile.py

changeset 8243
cc717c2ae956
parent 8230
8b5c6896655b
child 8273
698ae46f40a4
equal deleted inserted replaced
8242:aa713ac50c0d 8243:cc717c2ae956
8 debugger. 8 debugger.
9 """ 9 """
10 10
11 import socket 11 import socket
12 import threading 12 import threading
13 import contextlib
13 14
14 from DebugUtilities import prepareJsonCommand 15 from DebugUtilities import prepareJsonCommand
15 16
16 17
17 def AsyncPendingWrite(file): 18 def AsyncPendingWrite(file):
107 buf = self.wpending.pop(0) 108 buf = self.wpending.pop(0)
108 except IndexError: 109 except IndexError:
109 break 110 break
110 111
111 try: 112 try:
112 try: 113 with contextlib.suppress(UnicodeEncodeError,
114 UnicodeDecodeError):
113 buf = buf.encode('utf-8', 'backslashreplace') 115 buf = buf.encode('utf-8', 'backslashreplace')
114 except (UnicodeEncodeError, UnicodeDecodeError):
115 pass
116 self.sock.sendall(buf) 116 self.sock.sendall(buf)
117 self.nWriteErrors = 0 117 self.nWriteErrors = 0
118 except OSError: 118 except OSError:
119 self.nWriteErrors += 1 119 self.nWriteErrors += 1
120 if self.nWriteErrors > self.maxtries: 120 if self.nWriteErrors > self.maxtries:

eric ide

mercurial