Reputation: 145
I have been trying to debug a massive PyTorch model in VScode.
The starting point of the code first processes a configuration file, and then runs a subprocess
containing the cofigs.
The issue is that after calling subprocess.call
functions, the VScode, the code is executed in an external sub-process, which does not allow to use breakpoint.
example code:
def main():
args = parse_args()
cmd = construct_cmd(args)
subprocess.call(cmd, shell=True)
where cmd
is the string command to be executed, but after this line, all breakpoints are ignored (probably because a sub-process runs this command.
Any solutions how to solve this?
Upvotes: 4
Views: 970
Reputation: 121
I had the same problem. After spending many hours and trying different things, like changing launch.json file and using different IDEs and pdb package, I accidentally found that removing shell=True
solves the problem! I don't know the reason but it works (it would be great if someone tells the reason). So it's enough to use the following code:
def main():
args = parse_args()
cmd = construct_cmd(args)
subprocess.call(cmd)
Upvotes: 0