Description
From @isvoboda on December 31, 2016 1:45
I have a problem debugging a multiprocess based app. A simple example is given, which, in the beginning, runs ok without any breakpoint. On the other hand, stepping to the line val = self.que.get(block=True, timeout=None)
crashes the debugger, or just loses a focus and the process is no more attachable by VSCode.
I am enclosing a log from debug console and both launches I have tried.
Environment data
VS Code version: 1.8.1
Python Extension version: 0.5.5
Python Version: 2.7.6
OS and version: XUbuntu 14.04.5
My launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Python",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "${config.python.pythonPath}",
"program": "${file}",
"cwd": "${workspaceRoot}",
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit",
"RedirectOutput"
]
},
{
"name": "External Terminal/Console",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "${config.python.pythonPath}",
"program": "${file}",
"cwd": "null",
"console": "externalTerminal",
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit"
]
}
]
}
Your settings.json:
Logs
Output from Python
output panel
Traceback (most recent call last):
File "/home/isvoboda/.vscode/extensions/donjayamanne.python-0.5.6/pythonFiles/PythonTools/visualstudio_py_debugger.py", line 1725, in loop
cmd()
File "/home/isvoboda/.vscode/extensions/donjayamanne.python-0.5.6/pythonFiles/PythonTools/visualstudio_py_debugger.py", line 1741, in command_step_into
assert thread._is_blocked
AssertionError
Output from Console window
(Help->Developer Tools menu)
TypeError: Cannot read property 'Threads' of null
at PythonDebugger.threadsRequest (/home/isvoboda/.vscode/extensions/donjayamanne.python-0.5.6/out/client/debugger/Main.js:321:27)
at PythonDebugger.DebugSession.dispatchRequest (/home/isvoboda/.vscode/extensions/donjayamanne.python-0.5.6/node_modules/vscode-debugadapter/lib/debugSession.js:427:22)
at PythonDebugger.ProtocolServer._handleData (/home/isvoboda/.vscode/extensions/donjayamanne.python-0.5.6/node_modules/vscode-debugadapter/lib/protocol.js:104:38)
at Socket.<anonymous> (/home/isvoboda/.vscode/extensions/donjayamanne.python-0.5.6/node_modules/vscode-debugadapter/lib/protocol.js:24:60)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at Socket.Readable.push (_stream_readable.js:134:10)
at Pipe.onread (net.js:543:20): Error: TypeError: Cannot read property 'Threads' of null
at PythonDebugger.threadsRequest (/home/isvoboda/.vscode/extensions/donjayamanne.python-0.5.6/out/client/debugger/Main.js:321:27)
at PythonDebugger.DebugSession.dispatchRequest (/home/isvoboda/.vscode/extensions/donjayamanne.python-0.5.6/node_modules/vscode-debugadapter/lib/debugSession.js:427:22)
at PythonDebugger.ProtocolServer._handleData (/home/isvoboda/.vscode/extensions/donjayamanne.python-0.5.6/node_modules/vscode-debugadapter/lib/protocol.js:104:38)
at Socket.<anonymous> (/home/isvoboda/.vscode/extensions/donjayamanne.python-0.5.6/node_modules/vscode-debugadapter/lib/protocol.js:24:60)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at Socket.Readable.push (_stream_readable.js:134:10)
at Pipe.onread (net.js:543:20)
at file:////usr/share/code/resources/app/out/vs/workbench/electron-browser/workbench.main.js:90:21136
at Object.v [as _notify] (file:////usr/share/code/resources/app/out/vs/workbench/electron-browser/workbench.main.js:32:13263)
at Object.enter (file:////usr/share/code/resources/app/out/vs/workbench/electron-browser/workbench.main.js:32:16768)
at _run (file:////usr/share/code/resources/app/out/vs/workbench/electron-browser/workbench.main.js:32:18089)
at _error (file:////usr/share/code/resources/app/out/vs/workbench/electron-browser/workbench.main.js:32:17606)
at file:////usr/share/code/resources/app/out/vs/workbench/electron-browser/workbench.main.js:85:1178
at _.e.dispatch (file:////usr/share/code/resources/app/out/vs/workbench/electron-browser/workbench.main.js:85:2523)
at _.e.handleData (file:////usr/share/code/resources/app/out/vs/workbench/electron-browser/workbench.main.js:85:2035)
at Socket.<anonymous> (file:////usr/share/code/resources/app/out/vs/workbench/electron-browser/workbench.main.js:85:1038)
at emitOne (events.js:96:13)e.onUnexpectedError @ shell.ts:541(anonymous function) @ shell.ts:457e.onUnexpectedError @ errors.ts:68o @ errors.ts:88done @ winjs.base.raw.js:1378v @ winjs.base.raw.js:1224enter @ winjs.base.raw.js:901_run @ winjs.base.raw.js:1068_chainedError @ winjs.base.raw.js:1031n @ winjs.base.raw.js:736then @ winjs.base.raw.js:1436enter @ winjs.base.raw.js:747_run @ winjs.base.raw.js:1068_setCompleteValue @ winjs.base.raw.js:1052v @ winjs.base.raw.js:1209enter @ winjs.base.raw.js:901_run @ winjs.base.raw.js:1068_error @ winjs.base.raw.js:1041(anonymous function) @ v8Protocol.ts:53e.dispatch @ v8Protocol.ts:136e.handleData @ v8Protocol.ts:104(anonymous function) @ v8Protocol.ts:41emitOne @ events.js:96emit @ events.js:188readableAddChunk @ _stream_readable.js:176Readable.push @ _stream_readable.js:134onread @ net.js:543
Actual behavior
Stepping the debug process leads to a crash of debugger or loss of process focus.
Expected behavior
Stepping through a program and printing 0.
Steps to reproduce:
Debug the provided code, ie step into the process (reader or writer), the debugger stops working and nothing happens. After that, try to run the debugger once more without stepping through the code. Following these steps I got the error posted above in the developer tools console.
#!/usr/bin/env python
import multiprocessing
import random
class Writer(multiprocessing.Process):
def __init__(self, que=None, out_pipe=None):
super(Writer, self).__init__()
self.daemon = True
self.que = que
def run(self):
while True:
data = random.uniform(0,1)
self.que.put(data, block=True, timeout=None)
class Reader(multiprocessing.Process):
def __init__(self, que=None, in_pipe=None):
super(Reader, self).__init__()
self.daemon = True
self.que = que
self.n_batch = 24
def run(self):
data = []
for _ in xrange(self.n_batch):
val = self.que.get(block=True, timeout=None)
print("Received: {}".format(val))
def main():
que = multiprocessing.Queue(maxsize=8)
writer = Writer(que=que)
reader = Reader(que=que)
writer.start()
reader.start()
reader.join()
if __name__ == "__main__":
main()
Copied from original issue: DonJayamanne/pythonVSCode#614