2986:cd4e2cab7eb2 | 2987:c99695c0f13a |
---|---|
2 | 2 |
3 # Copyright (c) 2009 - 2013 Detlev Offenbach <detlev@die-offenbachs.de> | 3 # Copyright (c) 2009 - 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 |
99 | 100 |
100 def close(self, closeit=False): | 101 def close(self, closeit=False): |
101 """ | 102 """ |
102 Public method to close the file. | 103 Public method to close the file. |
103 | 104 |
104 @param closeit flag to indicate a close ordered by the debugger code (boolean) | 105 @param closeit flag to indicate a close ordered by the debugger code |
106 (boolean) | |
105 """ | 107 """ |
106 if closeit and not self.closed: | 108 if closeit and not self.closed: |
107 self.flush() | 109 self.flush() |
108 self.sock.close() | 110 self.sock.close() |
109 self.closed = True | 111 self.closed = True |
299 self.__checkMode('w') | 301 self.__checkMode('w') |
300 tries = 0 | 302 tries = 0 |
301 if not self.wpending: | 303 if not self.wpending: |
302 self.wpending = s | 304 self.wpending = s |
303 elif len(self.wpending) + len(s) > self.maxbuffersize: | 305 elif len(self.wpending) + len(s) > self.maxbuffersize: |
304 # flush wpending so that different string types are not concatenated | 306 # flush wpending so that different string types are not |
307 # concatenated | |
305 while self.wpending: | 308 while self.wpending: |
306 # if we have a persistent error in sending the data, an exception | 309 # if we have a persistent error in sending the data, an |
307 # will be raised in __nWrite | 310 # exception will be raised in __nWrite |
308 self.flush() | 311 self.flush() |
309 tries += 1 | 312 tries += 1 |
310 if tries > self.maxtries: | 313 if tries > self.maxtries: |
311 raise socket.error("Too many attempts to send data") | 314 raise socket.error("Too many attempts to send data") |
312 self.wpending = s | 315 self.wpending = s |