I tryied to come with a elegant solution fot easily removing handlers from blender.

I was thinking in something like that. The cool part is that in this case you can have independent namespaces for each handler that is a instance of class.

But I would like to hear from the experient addon writers if that gona work well, I find handlers a bit scary to work with.

like: when I try to call an mode_set operator from one of these handlers, the traceback freak out and blender craches.

import bpy
from bpy.app.handlers import persistent

class WrappingHandler:

    def __init__(self, handler_list = None):

        self.handler_list = handler_list
        if handler_list is not None:
            print("handler appended")

    def setup(self):

    def __call__(self, scene):

    def destroy(self):

    def wrapper(self, scene):
        return self.__call__(scene)

class AutoDestructibleHandler(WrappingHandler):

    def __call__(self, scene):



if __name__ == "__main__":
  • $\begingroup$ okay, I'll do that. $\endgroup$ – Jeacom Apr 1 '18 at 2:30
  • $\begingroup$ I find using a prefix on my handler method names and [hander.remove(f) for f in hander if f.__name__.startswith("PREFIX")] to remove them all, is a rather bulletproof, if not elegant, solution, $\endgroup$ – batFINGER Apr 1 '18 at 13:11

Your Answer

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

Browse other questions tagged or ask your own question.