From e69d534dae0f32ae154ebd7bfb264913b7116ab7 Mon Sep 17 00:00:00 2001 From: Karthik Nadig Date: Wed, 20 Jun 2018 13:35:34 -0700 Subject: [PATCH] Fix for KeyError in suspended event handle during attach (#507) * Fix for KeyError in suspended event handle during attach * Fix typo * Address comments. --- ptvsd/wrapper.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ptvsd/wrapper.py b/ptvsd/wrapper.py index 33eb1e71..b4f4846c 100644 --- a/ptvsd/wrapper.py +++ b/ptvsd/wrapper.py @@ -2181,7 +2181,12 @@ class VSCodeMessageProcessor(VSCLifecycleMsgProcessor): self.pydevd_notify(pydevd_comm.CMD_THREAD_RUN, pyd_tid) return - vsc_tid = self.thread_map.to_vscode(pyd_tid, autogen=False) + # NOTE: We should add the thread to VSC thread map only if the + # thread is seen here for the first time in 'attach' scenario. + # If we are here in 'launch' scenario and we get KeyError then + # there is an issue in reporting of thread creation. + autogen = self.start_reason == 'attach' + vsc_tid = self.thread_map.to_vscode(pyd_tid, autogen=autogen) with self.stack_traces_lock: self.stack_traces[pyd_tid] = xml.thread.frame