4
$\begingroup$

Some add-ons can add their own handlers which may cause errors or even crash.

How to tell which functions are causing problems?

Asking on behalf of this report.

$\endgroup$

1 Answer 1

5
$\begingroup$

You can write functions which intercept the existing functions and print out information, eg:

Given the following test example:

import bpy
def test_handler_a(scene):
    print("  Some Pre Handler", scene)
bpy.app.handlers.frame_change_pre.append(test_handler_a)

def test_handler_b(scene):
    print("  Some Post Handler", scene)
bpy.app.handlers.frame_change_post.append(test_handler_b)

This script sets up intercepting functions that print out all handlers that run:

import bpy
import sys

def intercept(fn, *args):
    print("Intercepting:", fn)
    sys.stdout.flush()

    fn(*args)

    print("... done")
    sys.stdout.flush()

for attr in dir(bpy.app.handlers):
    if attr.startswith("_"):
        continue

    handler_list = getattr(bpy.app.handlers, attr)
    if not isinstance(handler_list, list):
        continue
    if not handler_list:
        continue

    print("Intercept Setup:", attr)

    handler_list[:] = [lambda *args: intercept(fn, *args) for fn in handler_list]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.