[IronPython] Sharing state between embedded PythonEngines

Chris Stoy chris.stoy at redstorm.com
Wed Apr 11 21:14:51 CEST 2007


Hi all,

 

I'm working on embedding IronPython in a C# application and would like
to have a single, global module where I expose my objects and run
scripts, and have multiple views into that state.

 

For example, I want to have one (or more) IronPython console views that
provide an interactive prompt that the user can type in and execute
code.  If I enter a function/variable in one of the consoles, then it is
also available in the others. (ie, I enter "x=1" in console A and in
console B I can say "print x" and see "1" output.)  I also want to
execute much larger, non-interactive scripts that a user can write and,
again, this state is shared across all my IronPython views.

 

So, am I just thinking about this wrong?  How are people embedding
IronPython in their apps?  It seems strange (and inefficient) to have to
create a new PythonEngine and add all the references and expose globals
every time I want to execute script.  Is there a way to share some of
this state?  Can this be done using EngineModules?

 

Any thoughts would be appreciated.

 

Thanks.

 

Chris.

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20070411/0d3c4a69/attachment.html>


More information about the Ironpython-users mailing list