MCPcopy Index your code
hub / github.com/fabioz/PyDev.Debugger / process_internal_commands

Method process_internal_commands

pydevd.py:1775–1874  ·  view source on GitHub ↗

This function processes internal commands.

(self, process_thread_ids: Optional[tuple] = None)

Source from the content-addressed store, hash-verified

1773 self._running_thread_ids = {}
1774
1775 def process_internal_commands(self, process_thread_ids: Optional[tuple] = None):
1776 """
1777 This function processes internal commands.
1778 """
1779 # If this method is being called before the debugger is ready to run we should not notify
1780 # about threads and should only process commands sent to all threads.
1781 ready_to_run = self.ready_to_run
1782
1783 dispose = False
1784 with self._main_lock:
1785 program_threads_alive = {}
1786 if ready_to_run:
1787 self.check_output_redirect()
1788
1789 all_threads = threadingEnumerate()
1790 program_threads_dead = []
1791 with self._lock_running_thread_ids:
1792 reset_cache = not self._running_thread_ids
1793
1794 for t in all_threads:
1795 if getattr(t, "is_pydev_daemon_thread", False):
1796 pass # I.e.: skip the DummyThreads created from pydev daemon threads
1797 elif isinstance(t, PyDBDaemonThread):
1798 pydev_log.error_once("Error in debugger: Found PyDBDaemonThread not marked with is_pydev_daemon_thread=True.")
1799
1800 elif is_thread_alive(t):
1801 if reset_cache:
1802 # Fix multiprocessing debug with breakpoints in both main and child processes
1803 # (https://youtrack.jetbrains.com/issue/PY-17092) When the new process is created, the main
1804 # thread in the new process already has the attribute 'pydevd_id', so the new thread doesn't
1805 # get new id with its process number and the debugger loses access to both threads.
1806 # Therefore we should update thread_id for every main thread in the new process.
1807 clear_cached_thread_id(t)
1808
1809 thread_id = get_thread_id(t)
1810 program_threads_alive[thread_id] = t
1811
1812 self.notify_thread_created(thread_id, t, use_lock=False)
1813
1814 # Compute and notify about threads which are no longer alive.
1815 thread_ids = list(self._running_thread_ids.keys())
1816 for thread_id in thread_ids:
1817 if thread_id not in program_threads_alive:
1818 program_threads_dead.append(thread_id)
1819
1820 for thread_id in program_threads_dead:
1821 self.notify_thread_not_alive(thread_id, use_lock=False)
1822
1823 cmds_to_execute = []
1824
1825 # Without self._lock_running_thread_ids
1826 if len(program_threads_alive) == 0 and ready_to_run:
1827 dispose = True
1828 else:
1829 curr_thread_id = get_current_thread_id(threadingCurrentThread())
1830 if process_thread_ids is None:
1831 # Actually process the commands now (make sure we don't have a lock for _lock_running_thread_ids
1832 # acquired at this point as it could lead to a deadlock if some command evaluated tried to

Callers 6

wait_for_ready_to_runMethod · 0.95
do_wait_suspendMethod · 0.95
wait_for_commandsMethod · 0.95
_on_runMethod · 0.80

Calls 15

check_output_redirectMethod · 0.95
notify_thread_createdMethod · 0.95
is_thread_aliveFunction · 0.90
clear_cached_thread_idFunction · 0.90
get_thread_idFunction · 0.90
get_current_thread_idFunction · 0.90
keysMethod · 0.80
exceptionMethod · 0.80
putMethod · 0.80

Tested by

no test coverage detected