-
Notifications
You must be signed in to change notification settings - Fork 68
Multiprocess debugging support #57
Comments
Currently just enabling
|
Does current version of PTVS support multi-process debugging? |
Nope. This is one of the new features that we'll get from pydevd. |
I am certain this is available today. |
I believe this is because pydevd is being imported from within PTVSD. Also, check the following docs in the header of
|
Also reported on developer community at https://developercommunity.visualstudio.com/content/problem/231012/pydev-debugger-breakpoints-wont-work-in-the-new-pr.html |
A note here: due to the way that things are wrapped I think ptvsd won't know how to talk to the newly created multiprocess, so, this won't be simple to add in the current structure. The main issue is that ptvsd expects an in-memory pydevd and requires patching it in some places instead of launching pydevd and then acting as a server to it to just translate what's needed to vscode (in which case it could just treat the spawned process as a new pydevd process and translate the threads from that process accordingly to vscode -- i.e.: vscode doesn't need to know about new processes, the adapter could do the needed work to send messages to the right process given the thread ids). Another thing is that the whole patching expects pydevd to be the main entry, not ptvsd (so, many other things would need to be patched for this to work). I think the main issue it was done this way is because pydevd doesn't communicate through the debug adapter protocol, so, ideally pydevd itself could communicate through the debug protocol (instead of needing ptvsd as a wrapper) and then have ptvsd work more as a customization layer of pydevd and launching customization. |
Well, I think this is still possible. PTVSD talks to pydevd using the pydev protocol (over a fake socket). So, when dealing with multi-process debugging, all we need to do is, get PTVSD to talk to pydevd over an actual socket! Isn't that all that's required? Or am I missing something? /cc @karthiknadig @fabioz |
Here's a proof of concept, managed to get this working very easily using existing code. Here's the source for the prototype DonJayamanne@4f16466 |
@karthiknadig That's pretty much what I did to get the above working, PTVSD is a DA in this case, and PyDevD is running in the child process. |
@DonJayamanne I think this would be the ideal solution -- I thought it'd be more work given the way customizations are done, but if you got it running with few changes, even better ;) This would probably fix a number of other issues as |
Agreed.
Agreed. This would be lot more efficient as well. |
@DonJayamanne are these changes planned? Your approach sounds like it's a huge step forward. Do you have a patch to share? I'd be psyched to take a look at it and try it locally. My current workarounds for multi-process debugging are cumbersome. |
Nice! 👍 |
Will this issue also cover Python multiprocessing's Pool().map? |
I couldn't get it to work, probably some setup issue. Please try this extension. {
"type": "python",
"env": {
"PYTHONPATH": "/Users/donjayamanne/Desktop/Development/vscode/ptvsd"
}
....
}, |
@int19h Got this working guys, had to make some changes at my end. |
The debugger in The work is being tracked here: #425 |
|
@DonJayamanne |
@sourabhXIII If you have the latest released version of the extension, then in the launch json put If you are using this on linux/mac with |
@karthiknadig
#!/usr/bin/env python
#coding: utf-8
import multiprocessing
multiprocessing.set_start_method('spawn')
from multiprocessing import Process, Event
import B
if __name__ == '__main__':
update_event = Event()
client_proc = Process(
args=(update_event,),
name="client",
target=B.TestFunc,
)
client_proc.start()
import time
time.sleep(100)
#!/usr/bin/env python
#coding: utf-8
import time
def TestFunc(a):
while True:
time.sleep(5)
print(a)
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: cur file",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"subProcess": true
}
]
} When setting a break point in A.py's 12-th line, and by clicking
So sad. It is still not usable for such a simple multiprocessing code? My VSCode is just updated this afternoon, ubuntu16.04. Its detail: 版本 1.34.0 |
This is not a debugger issue - the same behavior can be observed running A.py directly. The reason is that this line: multiprocessing.set_start_method('spawn') must be inside the |
@int19h Thanks for your reply. It works for my pasted A.py and B.py example. Actually I was trying debugging a large python program and I'll try if it also works when it is available. |
pydev is currently started in single process mode. we need to pass
--multiprocess
flag as a command line arg. That may not be enough, we may need custom protocol messages to tell VS/VSC adapter that another process has started.The text was updated successfully, but these errors were encountered: