views:

61

answers:

1

I would like to create an ASP.NET MVC web application which has extensible logic that does not require a re-build. I was thinking of creating a filter which had an instance of the IronPython engine. What I would like to know is: how much overhead is there in creating a new engine during each web request, and would it be a better idea to keep a static engine around? However, if I were to keep a single static engine around, what are the issues I might run into as far as locking and script scope? Is it possible to have multiple scopes in the same IropPython engine so I don't get variable collision and security issues between web requests?

+3  A: 

I've just started using IronPython as extensibility point in my ASP.NET MVC aplication. I have one ipy engine (in static property) and for each request I create new scope and execute the script in that scope.
Each scope should be independent on other scopes, no locking is needed.

If I run into issues, I'll post it here. However, I don't expect any ;)

stej
This is definitely the recommended approach. ScriptEngine's aren't hugely expensive by themselves but compiling code is pretty expensive. If you re-use the same CompiledCode object you save a lot especially if you have the Python standard libray around which imports about 10 files on startup.
Dino Viehland