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

Class CheckAliveThread

pydevd.py:302–346  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

300# Non-daemon thread: guarantees that all data is written even if program is finished
301# =======================================================================================================================
302class CheckAliveThread(PyDBDaemonThread):
303 def __init__(self, py_db):
304 PyDBDaemonThread.__init__(self, py_db)
305 self.name = "pydevd.CheckAliveThread"
306 self.daemon = False
307 self._wait_event = ThreadingEvent()
308
309 @overrides(PyDBDaemonThread._on_run)
310 def _on_run(self):
311 py_db = self.py_db
312
313 def can_exit():
314 with py_db._main_lock:
315 # Note: it's important to get the lock besides checking that it's empty (this
316 # means that we're not in the middle of some command processing).
317 writer = py_db.writer
318 writer_empty = writer is not None and writer.empty()
319
320 return not py_db.has_user_threads_alive() and writer_empty
321
322 try:
323 while not self._kill_received:
324 self._wait_event.wait(TIMEOUT_SLOW)
325 if can_exit():
326 break
327
328 py_db.check_output_redirect()
329
330 if can_exit():
331 pydev_log.debug("No threads alive, finishing debug session")
332 py_db.dispose_and_kill_all_pydevd_threads()
333 except:
334 pydev_log.exception()
335
336 def join(self, timeout=None):
337 # If someone tries to join this thread, mark it to be killed.
338 # This is the case for CherryPy when auto-reload is turned on.
339 self.do_kill_pydev_thread()
340 PyDBDaemonThread.join(self, timeout=timeout)
341
342 @overrides(PyDBDaemonThread.do_kill_pydev_thread)
343 def do_kill_pydev_thread(self):
344 PyDBDaemonThread.do_kill_pydev_thread(self)
345 # Set flag so that it can exit before the usual timeout.
346 self._wait_event.set()
347
348
349class AbstractSingleNotificationBehavior(object):

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected