Hot-reloading #1151
Replies: 2 comments
-
This might be a regression due to #1059, which arrived in nanobind 2.8.0. Can you check whether the issue was present before that? What Python version are you running? What's the "black magic" that your tool is doing? Can you provide a reproducible example in terms of specific operations in importlib etc? |
Beta Was this translation helpful? Give feedback.
-
Afraid I don't know without digging quite a bit, I don't like Panel but there aren't many better alternatives so would need to try and work that out
Probably. I was simulating mortgage calculations so fingers crossed it might be a bit until I have spare time though 😅 I can try a build against an older nanobind release version with the MRE. I am using 3.13 here I think. I'll also see if I can get some tracing on the C++ side, that should make it clearer. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I'm working on a Panel applet; after moving the numerical work into C++, I am having some problems with the hot-reloading it seems. When I save a file and panel does whatever black magic to reload the files in the Python interpreter, it seems the nanobind module definition is being called again.
The issue I have is that if I guard against redefining things in NB_MODULE, on the reload types are missing from the module. Whilst if I don't the application aborts with e.g.:
So it seems somehow at least one enum is persisting across the reload whilst other classes are not.
Does nanobind support reloading through whatever importlib stuff is happening, is this a known limitation or should it "just work"? I'm not au fait with what happens behind the scenes when a module is reloaded but it seems odd as I'd hope either everything gets thrown away and starts again or persists in memory and should be guarded against given it's a native code module. I won't be surprised however if not given Python hasn't exactly grasped RAII yet ;)
Thanks
Beta Was this translation helpful? Give feedback.
All reactions