Skip to content

lisa.utils: Speedup Loggable.get_logger()

FIX

Logging directly or indirectly inside a destructor (del) is problematic as they are invoked when the world is breaking down around them, which can trigger some harmless exceptions. For this reason, get_logger() was returning a dummy logger if del was found in the stack.

inspect.stack() is unfortunately really slow (150ms to get a stack frame of depth 25), which is enough to really slowdown the import of some modules and runtime code as well.

Fix that by returning a wrapped logger object that will only inpsect the stack if an exception is raised.

Merge request reports