IronPython托管缓存导入模块? [英] IronPython hosting caching imported module?

查看:64
本文介绍了IronPython托管缓存导入模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将IronPython嵌入到我的应用程序中.一切正常,但是我发现当我使用CreateScriptSourceFromFile执行文件时,似乎IronPython缓存了其他导入的模块.

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.

例如,我有另一个文件为foo.py:

For example I have another file as foo.py:

foo = 'foo'

然后我使用IronPython托管API执行bar.py:

And I use IronPython hosting API to execute bar.py:

from foo import foo
print foo

如果我对bar.py进行了更改,那么在不退出主机应用程序的情况下,我可以看到所做的更改生效.但是,如果编辑foo.py,则必须重新启动应用程序才能看到更改.我已经在选项中启用了Debug,但无济于事.

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.

请咨询.非常感谢.

推荐答案

是的,导入的模块由ScriptEngine实例缓存.如果要自动重新加载缓存的模块,则必须创建一个新的引擎实例.当前无法禁用它并始终重新加载模块.

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.

这篇关于IronPython托管缓存导入模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆