Don't notify about threads before the debugger is ready to run. ptvsd:1919
@@ -1411,13 +1411,19 @@ class PyDB(object):
self._running_thread_ids = {}
def process_internal_commands(self):
- '''This function processes internal commands
'''
+ This function processes internal commands.
+ '''
+ # If this method is being called before the debugger is ready to run we should not notify
+ # about threads and should only process commands sent to all threads.
+ ready_to_run = self.ready_to_run
+
dispose = False
with self._main_lock:
+ program_threads_alive = {}
+ if ready_to_run:
self.check_output_redirect()
- program_threads_alive = {}
all_threads = threadingEnumerate()
program_threads_dead = []
with self._lock_running_thread_ids:
@@ -1453,15 +1459,19 @@ class PyDB(object):
self.notify_thread_not_alive(thread_id, use_lock=False)
# Without self._lock_running_thread_ids
- if len(program_threads_alive) == 0:
+ if len(program_threads_alive) == 0 and ready_to_run:
dispose = True
else:
# Actually process the commands now (make sure we don't have a lock for _lock_running_thread_ids
# acquired at this point as it could lead to a deadlock if some command evaluated tried to
# create a thread and wait for it -- which would try to notify about it getting that lock).
curr_thread_id = get_current_thread_id(threadingCurrentThread())
+ if ready_to_run:
+ process_thread_ids = (curr_thread_id, '*')
+ else:
+ process_thread_ids = ('*',)
- for thread_id in (curr_thread_id, '*'):
+ for thread_id in process_thread_ids:
queue = self.get_internal_queue(thread_id)
# some commands must be processed by the thread itself... if that's the case,
