Reputation: 10236
I'm trying to debug a Python subprocess (launched with multiprocess). I've created a simpler project with only the following code, launched the remote debugger, and then launched the project. I expect Eclipse to break on the settrace statement.
import multiprocessing
import pydevd
def new_proc():
print("New Procedure.")
pydevd.settrace()
print("After settrace.")
p = multiprocessing.Process(target=new_proc)
p.start()
p.join()
I see output from the first print statement, but not from the second, and no break is performed.
I then sent settrace() the "suspend" parameter with False.
import multiprocessing
import pydevd
def new_proc():
print("New Procedure.")
pydevd.settrace(suspend=False)
print("After settrace.")
p = multiprocessing.Process(target=new_proc)
p.start()
p.join()
This time, I see both messages as expected. I then set a breakpoint on the second print statement, and ran again. Now, I no longer see the second message.
Therefore, it looks as if Eclipse is breaking execution when it's supposed to, but not returning control to me. Is there something that I'm missing?
Upvotes: 2
Views: 1625
Reputation: 25332
Well, if that's your exact code and you're on Windows, the problem is that you're not setting up the multiprocessing properly (you need to check for the freeze_support())... that is, providing that you're starting the remote debugger properly too: http://pydev.org/manual_adv_remote_debugger.html
I.e.:
import multiprocessing
import pydevd
def new_proc():
print("New Procedure.")
pydevd.settrace()
print("After settrace.")
if __name__ == '__main__':
multiprocessing.freeze_support()
p = multiprocessing.Process(target=new_proc)
p.start()
p.join()
Upvotes: 4