[IronPython] Multi threaded engine

Dino Viehland dinov at microsoft.com
Mon Jun 7 23:30:05 CEST 2010



Christos wrote:
> Thanks Jeff,
> This is the recommendation I was expecting to get.
> I will run a high concurrency test on a single engine and single
> compiled
> code, with new scopes for each request and see where it takes me.
> Do I need any locks on the engine itself when Getting the scope (which
> could
> be called from many threads at the same time)?

Nope - no locks required.

> 
> I have another question related to performance.
> Right now I have a number of parameters that I need to pass to the
> CompiledCode and I use Microsoft.Scripting.ScopeStorage.SetValue and
> then
> create the scope using this.
> Is there a more efficient way to pass parameters to the CompiledCode?
> Like
> creating an single "parameter" object which is well known by both the
> IronPython code and my C# code?

The best way is to create the storage for the scope yourself.  Right now
the simplest (and sure to work) way to do that is to implement IAttributesCollection 
and create a scope using that for the storage.  Then you can respond to
the lookups lazily.  But setting multiple variables on a scope shouldn't
be that expensive (at least in 2.6.1 - there were some issues w/ that in 
2.6).



More information about the Ironpython-users mailing list