1

My python code freezes from time to time. I'm not sure what part runs into the error. My suspect would be a database connection or some external library.

What would be the easiest way to find the function call that causes the freeze?

I tried to attach to the process, but unfortunately, I couldn't pause/debug the main thread.

Right now I would just add logging messages to locate the error. But was wondering if there might be a better way.

Thanks a lot!

MichaelRazum
  • 789
  • 1
  • 10
  • 26
  • you can check which function is called by using inspect. https://stackoverflow.com/questions/2654113/how-to-get-the-callers-method-name-in-the-called-method – Pratik Mar 02 '19 at 18:42
  • that would be like logging right? I mean the process freezes. Though there is some way to analyze it with a different second python process or somehow attach to it and find what went wrong. – MichaelRazum Mar 02 '19 at 18:44
  • Correct me if I am wrong, but I am assuming that by process freeze you mean race conditions. – Pratik Mar 02 '19 at 18:53
  • Not sure what you understand under race condition. It just doesn't move on to the next function call it supposed to perform. So I can locate the error. But not sure where exactly the process is stuck. – MichaelRazum Mar 02 '19 at 19:16
  • Hmm...if there are multiple threads then there could be a deadlock.see this https://stackoverflow.com/questions/499634/how-to-detect-and-debug-multi-threading-problems. I don't know what exactly is there in code but if the code freezes then deadlock would be my best bet. – Pratik Mar 02 '19 at 19:20
  • No it should be a deadlock. just a database connection may be. But not sure to be honest. – MichaelRazum Mar 02 '19 at 19:45

0 Answers0