[Python.NET] ANNOUNCE: Python for .NET beta 5 now available

Brian Lloyd brian at zope.com
Thu Mar 31 16:44:18 CEST 2005


Yes, if you can send a test case that would help.

Note that to be thread-safe and reentrancy-safe you 
also need to make sure that any managed code you have 
that uses Python.Runtime objects or methods is acquiring 
the Python lock first. For example:

public class Example {

  public static int MethodThatCallsPython() {
    // have to acquire the GIL to safely call back into
    // Python!!
    IntPtr state = PythonEngine.AcquireLock();

    PythonEngine.RunSimpleString("print 'hello'");

    // done using python for now, so release the GIL...
    PythonEngine.ReleaseLock(state);
  }

}

Forgetting to manage the lock around a callback into Python 
is almost certain to cause a NullReferenceException (because 
there will be no valid thread state when the callback is 
made).


Brian Lloyd        brian at zope.com
V.P. Engineering   540.361.1716              
Zope Corporation   http://www.zope.com 


> -----Original Message-----
> From: pythondotnet-bounces at python.org
> [mailto:pythondotnet-bounces at python.org]On Behalf Of Roman Yakovenko
> Sent: Thursday, March 31, 2005 12:52 AM
> Cc: pythondotnet at python.org
> Subject: Re: [Python.NET] ANNOUNCE: Python for .NET beta 5 now available
> 
> 
> Hi. First of all thank you. 
> 
> Second - I still have problems to call static function from a few
> threads. Is it intentional?
> Do you want I send you test case?
> 
> Roman
> 
> 
> On Mar 29, 2005 5:31 AM, Brian Lloyd <brian at zope.com> wrote:
> > Python for .NET 1.0 beta 5 is now available - you can download
> > it from:
> > 
> >   http://www.zope.org/Members/Brian/PythonNet/
> > 
> > Python for .NET is a near-seamless integration of Python with the
> > .NET common language runtime. For more details, see the README:
> > 
> >   http://www.zope.org/Members/Brian/PythonNet/README.html
> > 
> > The beta 5 release features a refactoring of thread management
> > support, making the runtime stable for multi-threaded applications,
> > as well as several improvements and bug-fixes.
> > 
> > Special thanks to all who sent in thread-related scenarios and test
> > cases! I have tried to incorporate as many of these as possible into
> > the unit tests - if you still have problems that you suspect may be
> > related to threading or interpreter lock issues, please let me know
> > asap.
> > 
> > There is also now a mailing list for discussion, questions and
> > issues related to Python for .NET at: pythondotnet at python.org.
> > 
> > To subscribe to the mailing list or read the online archives, see:
> > 
> >   http://mail.python.org/mailman/listinfo/pythondotnet
> > 
> > Brian Lloyd        brian at zope.com
> > V.P. Engineering   540.361.1716
> > Zope Corporation   http://www.zope.com
> > 
> > _________________________________________________
> > Python.NET mailing list - PythonDotNet at python.org
> > http://mail.python.org/mailman/listinfo/pythondotnet
> >
> _________________________________________________
> Python.NET mailing list - PythonDotNet at python.org
> http://mail.python.org/mailman/listinfo/pythondotnet
> 


More information about the PythonDotNet mailing list