From 45738976bd1fd193a01f153bffcfce10a164f1f0 Mon Sep 17 00:00:00 2001 From: Fabio Zadrozny Date: Mon, 11 Nov 2019 10:51:46 -0300 Subject: [PATCH] Make it possible to process commands in secondary threads before the debugger is ready to run. --- src/ptvsd/_vendored/pydevd/pydevd.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/ptvsd/_vendored/pydevd/pydevd.py b/src/ptvsd/_vendored/pydevd/pydevd.py index 4025f333..7066b94c 100644 --- a/src/ptvsd/_vendored/pydevd/pydevd.py +++ b/src/ptvsd/_vendored/pydevd/pydevd.py @@ -164,7 +164,7 @@ class PyDBCommandThread(PyDBDaemonThread): @overrides(PyDBDaemonThread._on_run) def _on_run(self): # Delay a bit this initialization to wait for the main program to start. - time.sleep(0.3) + self._py_db_command_thread_event.wait(0.3) if self._kill_received: return @@ -1253,6 +1253,9 @@ class PyDB(object): else: internal_cmd = InternalThreadCommand(thread_id, method, *args, **kwargs) self.post_internal_command(internal_cmd, thread_id) + if thread_id == '*': + # Notify so that the command is handled as soon as possible in the PyDBCommandThread. + self._py_db_command_thread_event.set() def post_internal_command(self, int_cmd, thread_id): """ if thread_id is *, post to the '*' queue""" @@ -2598,11 +2601,11 @@ def _locked_settrace( if not wait_for_ready_to_run: py_db.ready_to_run = True + py_db.start_auxiliary_daemon_threads() + while not py_db.ready_to_run: time.sleep(0.1) # busy wait until we receive run command - py_db.start_auxiliary_daemon_threads() - if trace_only_current_thread: py_db.enable_tracing() else: