Debugging Funcanimation Update/Animate Function

I have been trying to search for this so long but there seems to be no answers. How do you debug the “update/animate” function that you pass into the funcanimation class? Example shown below.

def animate(k):
   # do stuff, update plots

anm = FuncAnimation(myFig, animate, interval=1, repeat=False)

Someone else asked the same question on https://stackoverflow.com/questions/62303358/debugging-funcanimation and no one seems to have a clue… Every time I put a breakpoint inside update function, the debug never stops there and the animation never happens. I am using Pycharm for IDE. Thanks and look forward to the solution of this issue.

[@tacaswell edited to addcode markup]

These functions can be tricky to debug because they are typically run from inside of a GUI event loop’s callback. In my experience trying to set a breakpoint() inside of these functions goes…badly.

The two tactics I have used to debug these functions is either directly calling them like


def animate(k):
   ...

animate(1)
animate(2)

which makes the code run on the main thread in the interpreter (where things like %debug and breakpoint() will work) or resorting to putting in a lot of print(...) statements (old-school but effective :slight_smile: ) .