svaante / dape

Debug Adapter Protocol for Emacs
GNU General Public License v3.0
448 stars 25 forks source link

Is Python multiprocessing supported? #90

Closed samuelsinayoko closed 4 months ago

samuelsinayoko commented 5 months ago

Does dape support Python code that uses multiprocessing? See example code below

#!/usr/bin/env python3
"""Print 'hello world'."""
import multiprocessing.pool
import multiprocessing

def myprint(i):
    print(i)
    return i

def foo_threads(workers=2):
    res = []
    if workers > 1:
        with multiprocessing.pool.ThreadPool(workers) as pool:
            res = pool.map(myprint, range(2))
    else:
        res = list(map(myprint, range(2)))
    print("returning from foo_theads, res = ", res)
    return res

def foo_processes(workers=2):
    res = []
    if workers > 1:
        with multiprocessing.Pool(workers) as pool:
            res = pool.map(myprint, range(2))
    else:
        res = list(map(myprint, range(2)))
    print("returning from foo_processes, res = ", res)
    return res

if __name__ == "__main__":
    print(foo_threads(1))
    print(foo_processes(1))
    print(foo_threads(2))
    print(foo_processes(2))

expected output

(venv-3.11) sinayoks@landade:~/dev/hello/ $ python example.py 
0
1
returning from foo_theads, res =  [0, 1]
[0, 1]
0
1
returning from foo_processes, res =  [0, 1]
[0, 1]
0
1
returning from foo_theads, res =  [0, 1]
[0, 1]
0
1
returning from foo_processes, res =  [0, 1]
[0, 1]

I'm able to hit the breakpoint when using a single worker/process (so no multiprocessing), but getting an operation not permitted error with 2 processes/threads when running this with M-x dape (`debugpy-module :cwd "/Users/sinayoks/dev/hello/" :module "example")

E+00000.980: Failed to kill Debuggee[PID=46834]

             Traceback (most recent call last):
               File "/Users/sinayoks/dev/hello/venv-3.11/lib/python3.11/site-packages/debugpy/launcher/../../debugpy/launcher/debuggee.py", line 190, in kill
                 os.killpg(process.pid, signal.SIGKILL)
             PermissionError: [Errno 1] Operation not permitted

             Stack where logged:
               File "/Users/sinayoks/dev/hello/venv-3.11/lib/python3.11/site-packages/debugpy/launcher/../../debugpy/launcher/debuggee.py", line 192, in kill
                 log.swallow_exception("Failed to kill {0}", describe())
               File "/Users/sinayoks/dev/hello/venv-3.11/lib/python3.11/site-packages/debugpy/launcher/../../debugpy/common/log.py", line 215, in swallow_exception
                 _exception(format_string, *args, **kwargs)
Screenshot 2024-03-13 at 14 06 48

Here's the *dape-repl* output

* Welcome to Dape REPL! *
Available Dape commands: debug, next, continue, pause, step, out, restart, kill, disconnect, quit
Empty input will rerun last command.

* Adapter started with "python -m debugpy.adapter" *
Process launched example
> c
> c
NameError       (note: full exception trace is shown but execution is paused at: _run_module_as_main):
    name 'foo_processes1' is not defined
> r
* Exit code: 247 *
* Adapter started with "python -m debugpy.adapter" *
Process launched example
> c
> c
> c
> c
* Adapter started with " -m debugpy.adapter" *
> 

and the *dape-events

[jsonrpc] e[14:03:13.671] --> initialize[1] {"type":"request","seq":1,"command":"initialize","arguments":{"clientID":"dape","adapterID":"python","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsRunInTerminalRequest":true,"supportsProgressReporting":true,"supportsStartDebuggingRequest":true}}
[jsonrpc] e[14:03:13.855] <-- output {"seq": 1, "type": "event", "event": "output", "body": {"category": "telemetry", "output": "ptvsd", "data": {"packageVersion": "1.8.1"}}}
[jsonrpc] e[14:03:13.855] <-- output {"seq": 2, "type": "event", "event": "output", "body": {"category": "telemetry", "output": "debugpy", "data": {"packageVersion": "1.8.1"}}}
[jsonrpc] e[14:03:13.855] <-- debugpySockets {"seq": 3, "type": "event", "event": "debugpySockets", "body": {"sockets": [{"host": "127.0.0.1", "port": 61377, "internal": false}]}}
[jsonrpc] e[14:03:13.855] <-- initialize[1] {"seq": 4, "type": "response", "request_seq": 1, "success": true, "command": "initialize", "body": {"supportsCompletionsRequest": true, "supportsConditionalBreakpoints": true, "supportsConfigurationDoneRequest": true, "supportsDebuggerProperties": true, "supportsDelayedStackTraceLoading": true, "supportsEvaluateForHovers": true, "supportsExceptionInfoRequest": true, "supportsExceptionOptions": true, "supportsFunctionBreakpoints": true, "supportsHitConditionalBreakpoints": true, "supportsLogPoints": true, "supportsModulesRequest": true, "supportsSetExpression": true, "supportsSetVariable": true, "supportsValueFormattingOptions": true, "supportsTerminateRequest": true, "supportsGotoTargetsRequest": true, "supportsClipboardContext": true, "exceptionBreakpointFilters": [{"filter": "raised", "label": "Raised Exceptions", "default": false, "description": "Break whenever any exception is raised."}, {"filter": "uncaught", "label": "Uncaught Exceptions", "default": true, "description": "Break when the process is exiting due to unhandled exception."}, {"filter": "userUnhandled", "label": "User Uncaught Exceptions", "default": false, "description": "Break when exception escapes into library code."}], "supportsStepInTargetsRequest": true}}
[jsonrpc] e[14:03:13.856] --> launch[2] {"type":"request","seq":2,"command":"launch","arguments":{"request":"launch","type":"python","cwd":"/Users/sinayoks/dev/hello/","module":"example","args":[],"justMyCode":false,"console":"integratedTerminal","showReturnValue":true,"stopAtEntry":true}}
[jsonrpc] e[14:03:13.857] <-- debugpySockets {"seq": 5, "type": "event", "event": "debugpySockets", "body": {"sockets": [{"host": "127.0.0.1", "port": 61377, "internal": false}, {"host": "127.0.0.1", "port": 61378, "internal": true}]}}
[jsonrpc] e[14:03:13.883] <-- debugpySockets {"seq": 6, "type": "event", "event": "debugpySockets", "body": {"sockets": [{"host": "127.0.0.1", "port": 61377, "internal": false}, {"host": "127.0.0.1", "port": 61379, "internal": true}, {"host": "127.0.0.1", "port": 61378, "internal": true}]}}
[jsonrpc] e[14:03:13.883] <-- runInTerminal[7] {"seq": 7, "type": "request", "command": "runInTerminal", "arguments": {"kind": "integrated", "title": "Python Debug Console", "args": ["/Users/sinayoks/dev/hello/venv-3.11/bin/python", "/Users/sinayoks/dev/hello/venv-3.11/lib/python3.11/site-packages/debugpy/launcher", "61379", "--", "-m", "example"], "env": {}, "cwd": "/Users/sinayoks/dev/hello/"}}
[jsonrpc] e[14:03:13.976] --> runInTerminal[7] {"type":"response","seq":7,"request_seq":7,"command":"runInTerminal","success":true,"body":{"processId":46993}}
[jsonrpc] e[14:03:14.445] <-- debugpySockets {"seq": 8, "type": "event", "event": "debugpySockets", "body": {"sockets": [{"host": "127.0.0.1", "port": 61377, "internal": false}, {"host": "127.0.0.1", "port": 61378, "internal": true}]}}
[jsonrpc] e[14:03:14.445] <-- initialized {"seq": 9, "type": "event", "event": "initialized"}
[jsonrpc] e[14:03:14.446] --> setExceptionBreakpoints[3] {"type":"request","seq":3,"command":"setExceptionBreakpoints","arguments":{"filters":["uncaught"]}}
[jsonrpc] e[14:03:14.453] <-- setExceptionBreakpoints[3] {"seq": 10, "type": "response", "request_seq": 3, "success": true, "command": "setExceptionBreakpoints"}
[jsonrpc] e[14:03:14.455] --> setBreakpoints[4] {"type":"request","seq":4,"command":"setBreakpoints","arguments":{"source":{"name":"example.py","path":"/Users/sinayoks/dev/hello/example.py"},"breakpoints":[{"line":7}],"lines":[7]}}
[jsonrpc] e[14:03:14.462] <-- setBreakpoints[4] {"seq": 11, "type": "response", "request_seq": 4, "success": true, "command": "setBreakpoints", "body": {"breakpoints": [{"verified": true, "id": 0, "source": {"name": "example.py", "path": "/Users/sinayoks/dev/hello/example.py"}, "line": 7}]}}
[jsonrpc] e[14:03:14.464] --> configurationDone[5] {"type":"request","seq":5,"command":"configurationDone"}
[jsonrpc] e[14:03:14.471] <-- configurationDone[5] {"seq": 12, "type": "response", "request_seq": 5, "success": true, "command": "configurationDone"}
[jsonrpc] i[14:03:14.471] [5] success ignored
[jsonrpc] e[14:03:14.471] <-- launch[2] {"seq": 13, "type": "response", "request_seq": 2, "success": true, "command": "launch"}
[jsonrpc] e[14:03:14.471] <-- process {"seq": 14, "type": "event", "event": "process", "body": {"startMethod": "launch", "isLocalProcess": true, "systemProcessId": 46996, "name": "example", "pointerSize": 64}}
[jsonrpc] e[14:03:14.527] <-- thread {"seq": 15, "type": "event", "event": "thread", "body": {"reason": "started", "threadId": 1}}
[jsonrpc] e[14:03:14.704] <-- stopped {"seq": 16, "type": "event", "event": "stopped", "body": {"reason": "breakpoint", "threadId": 1, "preserveFocusHint": false, "allThreadsStopped": true}}
[jsonrpc] e[14:03:14.704] --> threads[6] {"type":"request","seq":6,"command":"threads"}
[jsonrpc] e[14:03:14.712] <-- threads[6] {"seq": 17, "type": "response", "request_seq": 6, "success": true, "command": "threads", "body": {"threads": [{"id": 1, "name": "MainThread"}]}}
[jsonrpc] e[14:03:14.712] --> stackTrace[7] {"type":"request","seq":7,"command":"stackTrace","arguments":{"threadId":1,"startFrame":0,"levels":1}}
[jsonrpc] e[14:03:14.716] <-- stackTrace[7] {"seq": 18, "type": "response", "request_seq": 7, "success": true, "command": "stackTrace", "body": {"stackFrames": [{"id": 2, "name": "myprint", "line": 7, "column": 1, "source": {"path": "/Users/sinayoks/dev/hello/example.py", "sourceReference": 0}}], "totalFrames": 5}}
[jsonrpc] e[14:03:14.718] --> scopes[8] {"type":"request","seq":8,"command":"scopes","arguments":{"frameId":2}}
[jsonrpc] e[14:03:14.718] <-- module {"seq": 19, "type": "event", "event": "module", "body": {"reason": "new", "module": {"id": 0, "name": "__main__", "path": "/Users/sinayoks/dev/hello/example.py"}}}
[jsonrpc] e[14:03:14.718] <-- module {"seq": 20, "type": "event", "event": "module", "body": {"reason": "new", "module": {"id": 1, "name": "runpy", "path": "/usr/local/Cellar/python@3.11/3.11.8/Frameworks/Python.framework/Versions/3.11/lib/python3.11/runpy.py"}}}
[jsonrpc] e[14:03:14.777] <-- scopes[8] {"seq": 21, "type": "response", "request_seq": 8, "success": true, "command": "scopes", "body": {"scopes": [{"name": "Locals", "variablesReference": 3, "expensive": false, "presentationHint": "locals", "source": {}}, {"name": "Globals", "variablesReference": 4, "expensive": false, "source": {}}]}}
[jsonrpc] e[14:03:14.779] --> stackTrace[9] {"type":"request","seq":9,"command":"stackTrace","arguments":{"threadId":1,"startFrame":1,"levels":19}}
[jsonrpc] e[14:03:14.780] --> variables[10] {"type":"request","seq":10,"command":"variables","arguments":{"variablesReference":3}}
[jsonrpc] e[14:03:14.799] <-- stackTrace[9] {"seq": 22, "type": "response", "request_seq": 9, "success": true, "command": "stackTrace", "body": {"stackFrames": [{"id": 5, "name": "foo_threads", "line": 16, "column": 1, "source": {"path": "/Users/sinayoks/dev/hello/example.py", "sourceReference": 0}}, {"id": 6, "name": "<module>", "line": 33, "column": 1, "source": {"path": "/Users/sinayoks/dev/hello/example.py", "sourceReference": 0}}, {"id": 7, "name": "_run_code", "line": 88, "column": 1, "source": {"path": "/usr/local/Cellar/python@3.11/3.11.8/Frameworks/Python.framework/Versions/3.11/lib/python3.11/runpy.py", "sourceReference": 0}, "presentationHint": "subtle"}, {"id": 8, "name": "_run_module_as_main", "line": 198, "column": 1, "source": {"path": "/usr/local/Cellar/python@3.11/3.11.8/Frameworks/Python.framework/Versions/3.11/lib/python3.11/runpy.py", "sourceReference": 0}, "presentationHint": "subtle"}], "totalFrames": 5}}
[jsonrpc] e[14:03:14.800] <-- variables[10] {"seq": 23, "type": "response", "request_seq": 10, "success": true, "command": "variables", "body": {"variables": [{"name": "i", "value": "0", "type": "int", "evaluateName": "i", "variablesReference": 0}]}}
[jsonrpc] e[14:03:16.307] --> continue[11] {"type":"request","seq":11,"command":"continue","arguments":{"threadId":1}}
[jsonrpc] e[14:03:16.324] <-- continue[11] {"seq": 24, "type": "response", "request_seq": 11, "success": true, "command": "continue", "body": {"allThreadsContinued": true}}
[jsonrpc] e[14:03:16.326] <-- continued {"seq": 25, "type": "event", "event": "continued", "body": {"threadId": 1, "allThreadsContinued": true}}
[jsonrpc] e[14:03:16.326] <-- stopped {"seq": 26, "type": "event", "event": "stopped", "body": {"reason": "breakpoint", "threadId": 1, "preserveFocusHint": false, "allThreadsStopped": true}}
[jsonrpc] e[14:03:16.326] --> threads[12] {"type":"request","seq":12,"command":"threads"}
[jsonrpc] e[14:03:16.333] <-- threads[12] {"seq": 27, "type": "response", "request_seq": 12, "success": true, "command": "threads", "body": {"threads": [{"id": 1, "name": "MainThread"}]}}
[jsonrpc] e[14:03:16.333] --> stackTrace[13] {"type":"request","seq":13,"command":"stackTrace","arguments":{"threadId":1,"startFrame":0,"levels":1}}
[jsonrpc] e[14:03:16.335] <-- stackTrace[13] {"seq": 28, "type": "response", "request_seq": 13, "success": true, "command": "stackTrace", "body": {"stackFrames": [{"id": 2, "name": "myprint", "line": 7, "column": 1, "source": {"path": "/Users/sinayoks/dev/hello/example.py", "sourceReference": 0}}], "totalFrames": 5}}
[jsonrpc] e[14:03:16.336] --> scopes[14] {"type":"request","seq":14,"command":"scopes","arguments":{"frameId":2}}
[jsonrpc] e[14:03:16.396] <-- scopes[14] {"seq": 29, "type": "response", "request_seq": 14, "success": true, "command": "scopes", "body": {"scopes": [{"name": "Locals", "variablesReference": 3, "expensive": false, "presentationHint": "locals", "source": {}}, {"name": "Globals", "variablesReference": 4, "expensive": false, "source": {}}]}}
[jsonrpc] e[14:03:16.398] --> stackTrace[15] {"type":"request","seq":15,"command":"stackTrace","arguments":{"threadId":1,"startFrame":1,"levels":19}}
[jsonrpc] e[14:03:16.398] --> variables[16] {"type":"request","seq":16,"command":"variables","arguments":{"variablesReference":3}}
[jsonrpc] e[14:03:16.419] <-- stackTrace[15] {"seq": 30, "type": "response", "request_seq": 15, "success": true, "command": "stackTrace", "body": {"stackFrames": [{"id": 5, "name": "foo_threads", "line": 16, "column": 1, "source": {"path": "/Users/sinayoks/dev/hello/example.py", "sourceReference": 0}}, {"id": 6, "name": "<module>", "line": 33, "column": 1, "source": {"path": "/Users/sinayoks/dev/hello/example.py", "sourceReference": 0}}, {"id": 7, "name": "_run_code", "line": 88, "column": 1, "source": {"path": "/usr/local/Cellar/python@3.11/3.11.8/Frameworks/Python.framework/Versions/3.11/lib/python3.11/runpy.py", "sourceReference": 0}, "presentationHint": "subtle"}, {"id": 8, "name": "_run_module_as_main", "line": 198, "column": 1, "source": {"path": "/usr/local/Cellar/python@3.11/3.11.8/Frameworks/Python.framework/Versions/3.11/lib/python3.11/runpy.py", "sourceReference": 0}, "presentationHint": "subtle"}], "totalFrames": 5}}
[jsonrpc] e[14:03:16.421] <-- variables[16] {"seq": 31, "type": "response", "request_seq": 16, "success": true, "command": "variables", "body": {"variables": [{"name": "i", "value": "1", "type": "int", "evaluateName": "i", "variablesReference": 0}]}}
[jsonrpc] e[14:03:18.619] --> continue[17] {"type":"request","seq":17,"command":"continue","arguments":{"threadId":1}}
[jsonrpc] e[14:03:18.624] <-- continue[17] {"seq": 32, "type": "response", "request_seq": 17, "success": true, "command": "continue", "body": {"allThreadsContinued": true}}
[jsonrpc] e[14:03:18.626] <-- continued {"seq": 33, "type": "event", "event": "continued", "body": {"threadId": 1, "allThreadsContinued": true}}
[jsonrpc] e[14:03:18.626] <-- stopped {"seq": 34, "type": "event", "event": "stopped", "body": {"reason": "breakpoint", "threadId": 1, "preserveFocusHint": false, "allThreadsStopped": true}}
[jsonrpc] e[14:03:18.627] --> threads[18] {"type":"request","seq":18,"command":"threads"}
[jsonrpc] e[14:03:18.633] <-- threads[18] {"seq": 35, "type": "response", "request_seq": 18, "success": true, "command": "threads", "body": {"threads": [{"id": 1, "name": "MainThread"}]}}
[jsonrpc] e[14:03:18.633] --> stackTrace[19] {"type":"request","seq":19,"command":"stackTrace","arguments":{"threadId":1,"startFrame":0,"levels":1}}
[jsonrpc] e[14:03:18.635] <-- stackTrace[19] {"seq": 36, "type": "response", "request_seq": 19, "success": true, "command": "stackTrace", "body": {"stackFrames": [{"id": 9, "name": "myprint", "line": 7, "column": 1, "source": {"path": "/Users/sinayoks/dev/hello/example.py", "sourceReference": 0}}], "totalFrames": 5}}
[jsonrpc] e[14:03:18.636] --> scopes[20] {"type":"request","seq":20,"command":"scopes","arguments":{"frameId":9}}
[jsonrpc] e[14:03:18.691] <-- scopes[20] {"seq": 37, "type": "response", "request_seq": 20, "success": true, "command": "scopes", "body": {"scopes": [{"name": "Locals", "variablesReference": 10, "expensive": false, "presentationHint": "locals", "source": {}}, {"name": "Globals", "variablesReference": 11, "expensive": false, "source": {}}]}}
[jsonrpc] e[14:03:18.695] --> stackTrace[21] {"type":"request","seq":21,"command":"stackTrace","arguments":{"threadId":1,"startFrame":1,"levels":19}}
[jsonrpc] e[14:03:18.695] --> variables[22] {"type":"request","seq":22,"command":"variables","arguments":{"variablesReference":10}}
[jsonrpc] e[14:03:18.721] <-- stackTrace[21] {"seq": 38, "type": "response", "request_seq": 21, "success": true, "command": "stackTrace", "body": {"stackFrames": [{"id": 5, "name": "foo_processes", "line": 26, "column": 1, "source": {"path": "/Users/sinayoks/dev/hello/example.py", "sourceReference": 0}}, {"id": 6, "name": "<module>", "line": 34, "column": 1, "source": {"path": "/Users/sinayoks/dev/hello/example.py", "sourceReference": 0}}, {"id": 7, "name": "_run_code", "line": 88, "column": 1, "source": {"path": "/usr/local/Cellar/python@3.11/3.11.8/Frameworks/Python.framework/Versions/3.11/lib/python3.11/runpy.py", "sourceReference": 0}, "presentationHint": "subtle"}, {"id": 8, "name": "_run_module_as_main", "line": 198, "column": 1, "source": {"path": "/usr/local/Cellar/python@3.11/3.11.8/Frameworks/Python.framework/Versions/3.11/lib/python3.11/runpy.py", "sourceReference": 0}, "presentationHint": "subtle"}], "totalFrames": 5}}
[jsonrpc] e[14:03:18.723] <-- variables[22] {"seq": 39, "type": "response", "request_seq": 22, "success": true, "command": "variables", "body": {"variables": [{"name": "i", "value": "0", "type": "int", "evaluateName": "i", "variablesReference": 0}]}}
[jsonrpc] e[14:03:22.979] --> continue[23] {"type":"request","seq":23,"command":"continue","arguments":{"threadId":1}}
[jsonrpc] e[14:03:22.984] <-- continue[23] {"seq": 40, "type": "response", "request_seq": 23, "success": true, "command": "continue", "body": {"allThreadsContinued": true}}
[jsonrpc] e[14:03:22.986] <-- continued {"seq": 41, "type": "event", "event": "continued", "body": {"threadId": 1, "allThreadsContinued": true}}
[jsonrpc] e[14:03:22.986] <-- stopped {"seq": 42, "type": "event", "event": "stopped", "body": {"reason": "breakpoint", "threadId": 1, "preserveFocusHint": false, "allThreadsStopped": true}}
[jsonrpc] e[14:03:22.987] --> threads[24] {"type":"request","seq":24,"command":"threads"}
[jsonrpc] e[14:03:22.995] <-- threads[24] {"seq": 43, "type": "response", "request_seq": 24, "success": true, "command": "threads", "body": {"threads": [{"id": 1, "name": "MainThread"}]}}
[jsonrpc] e[14:03:22.995] --> stackTrace[25] {"type":"request","seq":25,"command":"stackTrace","arguments":{"threadId":1,"startFrame":0,"levels":1}}
[jsonrpc] e[14:03:22.997] <-- stackTrace[25] {"seq": 44, "type": "response", "request_seq": 25, "success": true, "command": "stackTrace", "body": {"stackFrames": [{"id": 9, "name": "myprint", "line": 7, "column": 1, "source": {"path": "/Users/sinayoks/dev/hello/example.py", "sourceReference": 0}}], "totalFrames": 5}}
[jsonrpc] e[14:03:22.999] --> scopes[26] {"type":"request","seq":26,"command":"scopes","arguments":{"frameId":9}}
[jsonrpc] e[14:03:23.049] <-- scopes[26] {"seq": 45, "type": "response", "request_seq": 26, "success": true, "command": "scopes", "body": {"scopes": [{"name": "Locals", "variablesReference": 10, "expensive": false, "presentationHint": "locals", "source": {}}, {"name": "Globals", "variablesReference": 11, "expensive": false, "source": {}}]}}
[jsonrpc] e[14:03:23.051] --> stackTrace[27] {"type":"request","seq":27,"command":"stackTrace","arguments":{"threadId":1,"startFrame":1,"levels":19}}
[jsonrpc] e[14:03:23.052] --> variables[28] {"type":"request","seq":28,"command":"variables","arguments":{"variablesReference":10}}
[jsonrpc] e[14:03:23.077] <-- stackTrace[27] {"seq": 46, "type": "response", "request_seq": 27, "success": true, "command": "stackTrace", "body": {"stackFrames": [{"id": 5, "name": "foo_processes", "line": 26, "column": 1, "source": {"path": "/Users/sinayoks/dev/hello/example.py", "sourceReference": 0}}, {"id": 6, "name": "<module>", "line": 34, "column": 1, "source": {"path": "/Users/sinayoks/dev/hello/example.py", "sourceReference": 0}}, {"id": 7, "name": "_run_code", "line": 88, "column": 1, "source": {"path": "/usr/local/Cellar/python@3.11/3.11.8/Frameworks/Python.framework/Versions/3.11/lib/python3.11/runpy.py", "sourceReference": 0}, "presentationHint": "subtle"}, {"id": 8, "name": "_run_module_as_main", "line": 198, "column": 1, "source": {"path": "/usr/local/Cellar/python@3.11/3.11.8/Frameworks/Python.framework/Versions/3.11/lib/python3.11/runpy.py", "sourceReference": 0}, "presentationHint": "subtle"}], "totalFrames": 5}}
[jsonrpc] e[14:03:23.079] <-- variables[28] {"seq": 47, "type": "response", "request_seq": 28, "success": true, "command": "variables", "body": {"variables": [{"name": "i", "value": "1", "type": "int", "evaluateName": "i", "variablesReference": 0}]}}
[jsonrpc] e[14:03:24.923] --> continue[29] {"type":"request","seq":29,"command":"continue","arguments":{"threadId":1}}
[jsonrpc] e[14:03:24.937] <-- continue[29] {"seq": 48, "type": "response", "request_seq": 29, "success": true, "command": "continue", "body": {"allThreadsContinued": true}}
[jsonrpc] e[14:03:24.939] <-- continued {"seq": 49, "type": "event", "event": "continued", "body": {"threadId": 1, "allThreadsContinued": true}}
[jsonrpc] e[14:03:24.951] <-- thread {"seq": 50, "type": "event", "event": "thread", "body": {"reason": "started", "threadId": 12}}
[jsonrpc] e[14:03:24.984] <-- thread {"seq": 51, "type": "event", "event": "thread", "body": {"reason": "started", "threadId": 13}}
[jsonrpc] e[14:03:24.987] <-- thread {"seq": 52, "type": "event", "event": "thread", "body": {"reason": "started", "threadId": 14}}
[jsonrpc] e[14:03:24.988] <-- thread {"seq": 53, "type": "event", "event": "thread", "body": {"reason": "started", "threadId": 15}}
[jsonrpc] e[14:03:24.991] <-- thread {"seq": 54, "type": "event", "event": "thread", "body": {"reason": "started", "threadId": 16}}
[jsonrpc] e[14:03:24.993] <-- stopped {"seq": 55, "type": "event", "event": "stopped", "body": {"reason": "breakpoint", "threadId": 12, "preserveFocusHint": false, "allThreadsStopped": true}}
[jsonrpc] e[14:03:24.994] --> threads[30] {"type":"request","seq":30,"command":"threads"}
[jsonrpc] e[14:03:25.001] <-- threads[30] {"seq": 56, "type": "response", "request_seq": 30, "success": true, "command": "threads", "body": {"threads": [{"id": 1, "name": "MainThread"}, {"id": 12, "name": "Thread-6 (worker)"}, {"id": 13, "name": "Thread-7 (worker)"}, {"id": 14, "name": "Thread-8 (_handle_workers)"}, {"id": 15, "name": "Thread-9 (_handle_tasks)"}, {"id": 16, "name": "Thread-10 (_handle_results)"}]}}
[jsonrpc] e[14:03:25.001] --> stackTrace[31] {"type":"request","seq":31,"command":"stackTrace","arguments":{"threadId":12,"startFrame":0,"levels":1}}
[jsonrpc] e[14:03:25.004] <-- stackTrace[31] {"seq": 57, "type": "response", "request_seq": 31, "success": true, "command": "stackTrace", "body": {"stackFrames": [{"id": 17, "name": "myprint", "line": 7, "column": 1, "source": {"path": "/Users/sinayoks/dev/hello/example.py", "sourceReference": 0}}], "totalFrames": 6}}
[jsonrpc] e[14:03:25.005] --> scopes[32] {"type":"request","seq":32,"command":"scopes","arguments":{"frameId":17}}
[jsonrpc] e[14:03:25.005] <-- module {"seq": 58, "type": "event", "event": "module", "body": {"reason": "new", "module": {"id": 2, "name": "multiprocessing.pool", "path": "/usr/local/Cellar/python@3.11/3.11.8/Frameworks/Python.framework/Versions/3.11/lib/python3.11/multiprocessing/pool.py", "package": "multiprocessing"}}}
[jsonrpc] e[14:03:25.006] <-- module {"seq": 59, "type": "event", "event": "module", "body": {"reason": "new", "module": {"id": 3, "name": "threading", "path": "/usr/local/Cellar/python@3.11/3.11.8/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py"}}}
[jsonrpc] e[14:03:25.056] <-- scopes[32] {"seq": 60, "type": "response", "request_seq": 32, "success": true, "command": "scopes", "body": {"scopes": [{"name": "Locals", "variablesReference": 18, "expensive": false, "presentationHint": "locals", "source": {}}, {"name": "Globals", "variablesReference": 19, "expensive": false, "source": {}}]}}
[jsonrpc] e[14:03:25.059] --> stackTrace[33] {"type":"request","seq":33,"command":"stackTrace","arguments":{"threadId":12,"startFrame":1,"levels":19}}
[jsonrpc] e[14:03:25.060] --> variables[34] {"type":"request","seq":34,"command":"variables","arguments":{"variablesReference":18}}
[jsonrpc] e[14:03:25.085] <-- stackTrace[33] {"seq": 61, "type": "response", "request_seq": 33, "success": true, "command": "stackTrace", "body": {"stackFrames": [{"id": 20, "name": "mapstar", "line": 48, "column": 1, "source": {"path": "/usr/local/Cellar/python@3.11/3.11.8/Frameworks/Python.framework/Versions/3.11/lib/python3.11/multiprocessing/pool.py", "sourceReference": 0}, "presentationHint": "subtle"}, {"id": 21, "name": "worker", "line": 125, "column": 1, "source": {"path": "/usr/local/Cellar/python@3.11/3.11.8/Frameworks/Python.framework/Versions/3.11/lib/python3.11/multiprocessing/pool.py", "sourceReference": 0}, "presentationHint": "subtle"}, {"id": 22, "name": "run", "line": 982, "column": 1, "source": {"path": "/usr/local/Cellar/python@3.11/3.11.8/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", "sourceReference": 0}, "presentationHint": "subtle"}, {"id": 23, "name": "_bootstrap_inner", "line": 1045, "column": 1, "source": {"path": "/usr/local/Cellar/python@3.11/3.11.8/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", "sourceReference": 0}, "presentationHint": "subtle"}, {"id": 24, "name": "_bootstrap", "line": 1002, "column": 1, "source": {"path": "/usr/local/Cellar/python@3.11/3.11.8/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", "sourceReference": 0}, "presentationHint": "subtle"}], "totalFrames": 6}}
[jsonrpc] e[14:03:25.087] <-- variables[34] {"seq": 62, "type": "response", "request_seq": 34, "success": true, "command": "variables", "body": {"variables": [{"name": "i", "value": "0", "type": "int", "evaluateName": "i", "variablesReference": 0}]}}
[jsonrpc] e[14:03:25.180] <-- startDebugging[63] {"seq": 63, "type": "request", "command": "startDebugging", "arguments": {"request": "attach", "configuration": {"type": "python", "cwd": "/Users/sinayoks/dev/hello/", "module": "example", "justMyCode": false, "console": "integratedTerminal", "showReturnValue": true, "stopAtEntry": true, "python": ["/Users/sinayoks/dev/hello/venv-3.11/bin/python"], "isOutputRedirected": false, "name": "Subprocess 47002", "subProcessId": 47002, "connect": {"host": "127.0.0.1", "port": 61377}}}}
[jsonrpc] e[14:03:25.182] --> startDebugging[63] {"type":"response","seq":63,"request_seq":63,"success":false,"message":"Internal error","body":null}
[jsonrpc] D[14:03:25.215] Connection state change: `exited abnormally with code 1
'

----------b---y---e---b---y---e----------
svaante commented 5 months ago

After some testing seams to be related to dape switching connection method with debugpy.

Please test how the following works for you:

debugpy-module command-args ("-m" "debugpy.adapter" "--host" "0.0.0.0" "--port" :autoport) port :autoport :cwd "/Users/sinayoks/dev/hello/" :module "example"

svaante commented 5 months ago

This change has been reverted, but the debugging experience for sub processes has been OK for one sub process but when the number grows as in your examples dape is not really that useful, but your issue motivated me to fix that. So I will have something ready in a few days.

Note sub process not threads, thread support should works with dape but sub process are handled by debugpy in an uniq way

samuelsinayoko commented 5 months ago

Tested your changes using commit 339cdef7d5f76da2cdaa2b679bb07e5ce8830edf and it now works on OSX s! Amazing stuff thanks so much @svaante! Am now able to hit the breakpoints in subprocesses.

svaante commented 5 months ago

Hey, I have pushed some changes that should make the multi process debuggin in debugpy useful

svaante commented 4 months ago

Closing as it seams to be working