0
votes

I have a non terminating python program that I debug with

import faulthandler
faulthandler.dump_traceback_later(480,exit=True)
call_very_complicated_python_code()

I want to profile it to gain better understanding which parts are stuck:

$ python -m cProfile -o program.prof my_program.py my_input.txt
  • Does faulhandler mechanism interfere with the profiling?
  • program.prof is not always generated.
  • Any way to solve this?
1

1 Answers

0
votes

I've not used faulthandler, but sounds like the wrong tool for the job anyway. If you code never ends or errors, where is the traceback coming from?

Profiling is used to measure the speed of your code. If you want to understand the code, I'd suggest debugging it with something like pdb.

Add import pdb up the top of your module(s).

In areas you'd like to stop and inspect add: pdb.set_trace()

Perhaps you have some recursion or loop which is never competed?