Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python cProfile and profile models skip functions

basically the cProfile module skips some functions when i run it, and the normal profile module produces this error.

    The debugged program raised the exception unhandled AssertionError
"('Bad call', ('objects/controller/StageController.py', 9, '__init__'), <frame object at 0x9bbc104>, <frame object at 0x9bb438c>, <frame object at 0x9bd0554>, <frame object at 0x9bcf2f4>)"
File: /usr/lib/python2.6/profile.py, Line: 301

ive done all the searches and i cant find anything. How do i make them work properly?

@ yk4ever

StageController.py class starts like this:

class StageControl(ObjectControl):

    def __init__(self, canvas_name):
        ObjectControl.__init__(self, canvas_name,"stage_object")
        self.model = StageModel()
        self.variables()
        self.make_stage()
        self.overrides()

the "Bad call" error above seems to dislike this class

like image 943
spearfire Avatar asked Mar 27 '26 00:03

spearfire


1 Answers

I've found the problem. Psyco the 'ObjectControl' class which my 'StageControl' inherited has a simple:

import psyco
psyco.full()

INSIDE the class, which caused the error hence only the methods in the classes which inherited 'ObjectControl', caused the profiler to fail. i read somewhere it was a good idea to import psyco only where it was necessary, turns out thats a bad idea.

I had used psyco for a time until i came across cython, but for some reason left the psyco import statements lying around long enough to bork the profiler. ive since dumped psyco.

the moral of the story is: just stick with cython, at the end of the day nothing beats C.

like image 168
spearfire Avatar answered Mar 28 '26 13:03

spearfire