[Python.NET] embedding in aspx problem

Laurian Gridinoc laur at gd.ro
Mon May 17 15:42:53 EDT 2004

On Mon, 2004-05-17 at 14:17, Brian Lloyd wrote:
> Try removing the call to PythonEngine.Finalize(). That should 
> _only_ be called when you are truly finished with the Python 
> interpreter (to clean up and free resources, etc.) That method 
> tears down the Python runtime environment and after it is called 
> you can't use Python anymore from any thread in the process.
> - Brian

The issue was with sys.path which when called from aspx, and not from an
exe was relative (.\lib, instead of d:\testsite\bin\lib) so I have to
set it like this before importing my module:

PyObject sys = PythonEngine.ImportModule("sys");
     PyObject path = sys.GetAttr("path");
     PyObject append = path.GetAttr("append");
     PyObject[] a = new PyObject[1];
     a[0] = new PyString("d:\\testsite\\bin\\lib");

Another issue, if I tear down the python runtime environment (not by
several finalize(), but by recurrent errors) how can I restore it
without restarting my application (in ASP.NET it seems I have to restart
the WWW Publishing service for this)

Thank you,

Laurian Gridinoc
Chief Developer

More information about the PythonDotNet mailing list