MCPcopy Create free account
hub / github.com/fabioz/PyDev.Debugger / ReaderThread

Class ReaderThread

tests_python/debugger_unittest.py:184–369  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

182# ReaderThread
183# =======================================================================================================================
184class ReaderThread(threading.Thread):
185 MESSAGES_TIMEOUT = 10
186
187 def __init__(self, sock):
188 threading.Thread.__init__(self)
189 self.name = "Test Reader Thread"
190 try:
191 from queue import Queue
192 except ImportError:
193 from Queue import Queue
194
195 self.daemon = True
196 self._buffer = b""
197 self.sock = sock
198 self._queue = Queue()
199 self._kill = False
200 self.accept_xml_messages = True
201 self.on_message_found = lambda msg: None
202
203 def set_messages_timeout(self, timeout):
204 self.MESSAGES_TIMEOUT = timeout
205
206 def get_next_message(self, context_message, timeout=None):
207 if timeout is None:
208 timeout = self.MESSAGES_TIMEOUT
209 try:
210 msg = self._queue.get(block=True, timeout=timeout)
211 self.on_message_found(msg)
212 except:
213 raise TimeoutError(
214 "No message was written in %s seconds. Error message:\n%s"
215 % (
216 timeout,
217 context_message,
218 )
219 )
220 else:
221 frame = sys._getframe().f_back.f_back
222 frame_info = ""
223 while frame:
224 if not frame.f_code.co_name.startswith("test_"):
225 frame = frame.f_back
226 continue
227
228 if frame.f_code.co_filename.endswith("debugger_unittest.py"):
229 frame = frame.f_back
230 continue
231
232 stack_msg = ' -- File "%s", line %s, in %s\n' % (frame.f_code.co_filename, frame.f_lineno, frame.f_code.co_name)
233 if "run" == frame.f_code.co_name:
234 frame_info = stack_msg # Ok, found the writer thread 'run' method (show only that).
235 break
236 frame_info += stack_msg
237 frame = frame.f_back
238 # Just print the first which is not debugger_unittest.py
239 break
240
241 frame = None

Callers 8

runMethod · 0.90
runMethod · 0.90
runMethod · 0.90
runMethod · 0.90
_set_socketMethod · 0.70

Calls

no outgoing calls

Tested by 8

runMethod · 0.72
runMethod · 0.72
runMethod · 0.72
runMethod · 0.72
_set_socketMethod · 0.56