Paul Harter wrote:
> To use python.net with it is fine as long as the initial import of clr
> takes place early on in the main thread. Otherwise it doesn't work on
> multi-processor machines. I don't know why.

import clr should always be the first thing you do in an app. "import
clr" loads and initializes the Python.Runtime assembly. During the
initialization Python's __import__ hook is replaced with a custom hook
for the CLR import magic. You can get in all kinds of trouble if you
replace __import__ in a thread while another threads tries to import an
assembly. Our you can suffer from an import dead lock. It's a race
condition.

In an embedded .NET or C/C++ app you shouldn't use clr. It's better to
import the Python.Runtime assembly and call its PythonEngine::InitExt()
static method. The sample implementation in
https://pythonnet.svn.sourceforge.net/svnroot/pythonnet/trunk/pythonnet/src/monoclr/pynetinit.c
contains a working example and some helpful notes from me. I run into a
problem with threads, too.

Christian
_________________________________________________
Python.NET mailing list - [email protected]
http://mail.python.org/mailman/listinfo/pythondotnet

Reply via email to