cProfile for Python does not recognize Function name cProfile for Python does not recognize Function name python python

cProfile for Python does not recognize Function name


The problem is that you imported send_email inside your method definition.

I suggest you to use runctx:

cProfile.runctx('send_email()', None, locals())

From the official documentation:

cProfile.runctx(command, globals, locals, filename=None)

This function is similar to run(), with added arguments to supply the globals and locals dictionaries for the command string.