[Ironpython-users] Reload module within embedded C# app
Daniel Fernandez
fernandez_dan2 at hotmail.com
Wed Dec 21 23:16:38 CET 2011
Hi Jeff, In my simple scenario was able to update test2. I just perform the followingvarsuccess = engine.GetSysModule().GetVariable("modules").Remove("test2"); then I perform the ImportModule on the test module and test2 was updated. I'm not sure if this is correct but I received the wanted effect. I will keep playing and thanks for the help. Danny
> Date: Wed, 21 Dec 2011 11:53:36 -0800
> Subject: Re: [Ironpython-users] Reload module within embedded C# app
> From: jdhardy at gmail.com
> To: fernandez_dan2 at hotmail.com
> CC: ironpython-users at python.org
>
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20111221/119925b5/attachment.html>
More information about the Ironpython-users
mailing list