Closed Aman-Anas closed 6 months ago
Hi,
Could you try to put this try/except inside the user code, i.e. near the first occurring import of imgui_bundle. It seems awkward to silently swallow error like this. I cannot make this change in production, since users may fail to see actual errors.
I was able to move the try/except logic to the user code, it's not particularly elegant but it works fine. I'm still not sure what the root cause of this issue is, but I think the fix is good enough for now. It's not as simple as wrapping the import in a try-except since the __init__.py
module is called at the beginning of module initialization, so catching the error externally doesn't end up importing the module. I had to make a workaround.
This is a bit of a weird usecase, but I'm testing out using
imgui_bundle
with UPBGE, a game engine integrated into Blender (However, I think this problem would be present for Blender addons as well). Basically, Blender retains the loaded library, and when trying to re-import imgui_bundle a second time after stopping and starting the engine runtime (in Blender-embedded mode) it fails to importimgui_bundle._imgui_bundle.imgui
correctly.It works fine in standalone player or export, so this probably has something to do with retaining state while the same process is open. Anyways, the simple fix I found was to just use a try-catch statement at the top of
imgui_bundle/__init__.py
to wrap the imports.I'm not sure if this would break anything, and maybe there is a more correct way to do this. In my tests however, it seems to work fine and it successfully imports the module.