DebugClients/Python/AsyncFile.py

changeset 2987
c99695c0f13a
parent 2953
703452a2876f
child 3021
801289962f4e
equal deleted inserted replaced
2986:cd4e2cab7eb2 2987:c99695c0f13a
2 2
3 # Copyright (c) 2002 - 2013 Detlev Offenbach <detlev@die-offenbachs.de> 3 # Copyright (c) 2002 - 2013 Detlev Offenbach <detlev@die-offenbachs.de>
4 # 4 #
5 5
6 """ 6 """
7 Module implementing an asynchronous file like socket interface for the debugger. 7 Module implementing an asynchronous file like socket interface for the
8 debugger.
8 """ 9 """
9 10
10 import socket 11 import socket
11 12
12 from DebugProtocol import EOT 13 from DebugProtocol import EOT
96 97
97 def close(self, closeit=0): 98 def close(self, closeit=0):
98 """ 99 """
99 Public method to close the file. 100 Public method to close the file.
100 101
101 @param closeit flag to indicate a close ordered by the debugger code (boolean) 102 @param closeit flag to indicate a close ordered by the debugger code
103 (boolean)
102 """ 104 """
103 if closeit and not self.closed: 105 if closeit and not self.closed:
104 self.flush() 106 self.flush()
105 self.sock.close() 107 self.sock.close()
106 self.closed = 1 108 self.closed = 1
273 tries = 0 275 tries = 0
274 if not self.wpending: 276 if not self.wpending:
275 self.wpending = s 277 self.wpending = s
276 elif type(self.wpending) != type(s) or \ 278 elif type(self.wpending) != type(s) or \
277 len(self.wpending) + len(s) > self.maxbuffersize: 279 len(self.wpending) + len(s) > self.maxbuffersize:
278 # flush wpending so that different string types are not concatenated 280 # flush wpending so that different string types are not
281 # concatenated
279 while self.wpending: 282 while self.wpending:
280 # if we have a persistent error in sending the data, an exception 283 # if we have a persistent error in sending the data, an
281 # will be raised in __nWrite 284 # exception will be raised in __nWrite
282 self.flush() 285 self.flush()
283 tries += 1 286 tries += 1
284 if tries > self.maxtries: 287 if tries > self.maxtries:
285 raise socket.error("Too many attempts to send data") 288 raise socket.error("Too many attempts to send data")
286 self.wpending = s 289 self.wpending = s

eric ide

mercurial