问题
I'm embedding IronPython in my application. Everything goes fine but I found that when I use CreateScriptSourceFromFile
to execute a file, it seems that IronPython cached other imported module.
For example I have another file as foo.py
:
foo = 'foo'
And I use IronPython hosting API to execute bar.py
:
from foo import foo
print foo
If I make changes to bar.py
then without exiting the host application I can see my changes made take effect. But if I edit foo.py
then I have to reboot my application to see the changes. I've already enabled Debug
in the options but it does not help.
Please advice. Thanks very much.
回答1:
Yes, imported modules are cached by the ScriptEngine instance. You'll have to create a new engine instance if you want to reload cached modules automatically. There's currently no way to disable that and always reload modules.
An option to disable the caching behaviour isn't a bad idea; open an issue so that it's on the radar. Patches are even better, of course.
来源:https://stackoverflow.com/questions/11625321/ironpython-hosting-caching-imported-module