IronPython hosting caching imported module?

大憨熊 提交于 2019-12-24 20:12:07

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!