Has anyone found a good way to use the importlib.reload() function? I just realized that every time this is called to reload a specific module, it completely reparses that module. That makes sense, but I guess I assumed Blender was only reloading these once per add-on refresh.

The problem is when multiple modules rely on the same higher-level module - if lower level modules reload the higher level module, it ends up getting reparsed for each one (every class redefined, every global reinitialized).

Currently, I've set it up so that only my main module reloads all sub-modules exactly one time. But to do this, I can't have crossed dependencies - modules have to be reloaded after their dependency modules. This may be a good thing anyway, but I'm worried it may not always work.

Is there a better way to handle this?

If anyone is curious to see how many times some of their files are being parsed, try adding this to the very top of each *.py: print( "parsing " + __name__)

  • $\begingroup$ Hi. When forming a question title please make it specific instead of just stating the general topic. Thanks. $\endgroup$ – Ray Mairlot Sep 22 at 14:56

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.