Skip to content

Commit 55c34e4

Browse files
committed
Add and remove threads Id upon debugger events
1 parent 492f9a0 commit 55c34e4

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

ipykernel/debugger.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,11 @@ class Debugger:
205205

206206
def __init__(self, log, debugpy_stream, event_callback, shell_socket, session):
207207
self.log = log
208-
self.debugpy_client = DebugpyClient(log, debugpy_stream, event_callback)
208+
self.debugpy_client = DebugpyClient(log, debugpy_stream, self._handle_event)
209209
self.shell_socket = shell_socket
210210
self.session = session
211211
self.is_started = False
212+
self.event_callback = event_callback
212213

213214
self.started_debug_handlers = {}
214215
for msg_type in Debugger.started_debug_msg_types:
@@ -227,6 +228,13 @@ def __init__(self, log, debugpy_stream, event_callback, shell_socket, session):
227228
self.debugpy_port = 0
228229
self.endpoint = None
229230

231+
def _handle_event(self, msg):
232+
if msg['event'] == 'stopped':
233+
self.stopped_threads.append(msg['body']['threadId'])
234+
elif msg['event'] == 'continued':
235+
self.stopped_threads.remove(msg['body']['threadId'])
236+
self.event_callback(msg)
237+
230238
async def _forward_message(self, msg):
231239
return await self.debugpy_client.send_dap_request(msg)
232240

@@ -302,11 +310,11 @@ async def source(self, message):
302310

303311
async def stackTrace(self, message):
304312
reply = await self._forward_message(message)
305-
# We stackFrames array has the following content:
313+
# The stackFrames array has the following content:
306314
# { frames from the notebook}
307315
# ...
308316
# { 'id': xxx, 'name': '<module>', ... } <= this is the first frame of the code from the notebook
309-
# { frame from ipykernel }
317+
# { frames from ipykernel }
310318
# ...
311319
# {'id': yyy, 'name': '<module>', ... } <= this is the first frame of ipykernel code
312320
# We want to remove all the frames from ipykernel

0 commit comments

Comments
 (0)