[Ironpython-users] Reload module within embedded C# app

Jeff Hardy jdhardy at gmail.com
Wed Dec 21 20:53:36 CET 2011


On Wed, Dec 21, 2011 at 11:32 AM, Daniel Fernandez
<fernandez_dan2 at hotmail.com> wrote:
> Hi Jeff,
>
> I downloaded NWSGI and see where you call engine.ImportModule in
> the WsgiApplication.GetApplicationInfo method. It works great with that
> module changes.
>
> I couldn't get modules that were changed from the entry module to update. I
> have python script test.py that imports test2, if test2.py the changes in
> the scope didn't reflect after engine.ImportModule on test.py. I was sure if
> there was a way to force a reload of test2 module. I figure if I can remove
> test2 module from sys.modules the next time I perform ImportModule on test
> it would reload test2, but I am not sure if this makes sense.

That's basically what you want to do. I'm not 100% up on the import
mechanism (it's a bit hairy) but that should do what you want.

The other option would be to completely recreate the ScriptEngine,
which is where the modules are stored. This is a bit more
time-consuming, but if scripts aren't changing constantly it shouldn't
be too bad.

- Jeff


More information about the Ironpython-users mailing list