Wei
Wei

Reputation: 738

Python thread debugging

I am debugging a python program with pdb. The program will start a new thread.

newThread = Thread(group = None,target = dosomething,name = "thename",
                               args = (),kwargs = {})

def dosomething():
    balaba

Use the normal pdb command e.g. -b to set break point in the line of the new thread(e.g. line of balaba), seems will not trigger the breakpoint.

The question I want to ask is: is there a way I can break into the new thread target function to look into the behavor the new thread?

Upvotes: 1

Views: 3885

Answers (1)

valdarin
valdarin

Reputation: 951

One problem to begin with, you have to explicitly start the thread by using .start() - they do not start automatically when you create your Thread object (assuming you are using Python's built in threading library?).

newThread.start()

then see if your line of code is triggered using your debug method.

Upvotes: 1

Related Questions