C# Класс Python.Runtime.PythonEngine

This class provides the public interface of the Python runtime.
Показать файл Открыть проект Примеры использования класса

Private Properties

Свойство Тип Описание

Открытые методы

Метод Описание
AcquireLock ( ) : IntPtr

AcquireLock Method

Acquire the Python global interpreter lock (GIL). Managed code *must* call this method before using any objects or calling any methods on objects in the Python.Runtime namespace. The only exception is PythonEngine.Initialize, which may be called without first calling AcquireLock. Each call to AcquireLock must be matched by a corresponding call to ReleaseLock, passing the token obtained from AcquireLock. For more information, see the "Extending and Embedding" section of the Python documentation on www.python.org.

BeginAllowThreads ( ) : IntPtr

BeginAllowThreads Method

Release the Python global interpreter lock to allow other threads to run. This is equivalent to the Py_BEGIN_ALLOW_THREADS macro provided by the C Python API. For more information, see the "Extending and Embedding" section of the Python documentation on www.python.org.

EndAllowThreads ( IntPtr ts ) : void

EndAllowThreads Method

Re-aquire the Python global interpreter lock for the current thread. This is equivalent to the Py_END_ALLOW_THREADS macro provided by the C Python API. For more information, see the "Extending and Embedding" section of the Python documentation on www.python.org.

ImportModule ( string name ) : PyObject

ImportModule Method

Given a fully-qualified module or package name, import the module and return the resulting module object as a PyObject or null if an exception is raised.

InitExt ( ) : IntPtr
InitExt ( ) : void
Initialize ( ) : void

Initialize Method

Initialize the Python runtime. It is safe to call this method more than once, though initialization will only happen on the first call. It is *not* necessary to hold the Python global interpreter lock (GIL) to call this method.

ModuleFromString ( string name, string code ) : PyObject

ModuleFromString Method

Given a string module name and a string containing Python code, execute the code in and return a module of the given name.

ReleaseLock ( IntPtr gs ) : void

ReleaseLock Method

Release the Python global interpreter lock using a token obtained from a previous call to AcquireLock. For more information, see the "Extending and Embedding" section of the Python documentation on www.python.org.

ReloadModule ( PyObject module ) : PyObject

ReloadModule Method

Given a PyObject representing a previously loaded module, reload the module.

RunSimpleString ( string code ) : int
RunString ( string code ) : PyObject

RunString Method

Run a string containing Python code. Returns the result of executing the code string as a PyObject instance, or null if an exception was raised.

RunString ( string code, IntPtr globals, IntPtr locals ) : PyObject
Shutdown ( ) : void

Shutdown Method

Shutdown and release resources held by the Python runtime. The Python runtime can no longer be used in the current process after calling the Shutdown method.

Описание методов

AcquireLock() публичный статический Метод

AcquireLock Method
Acquire the Python global interpreter lock (GIL). Managed code *must* call this method before using any objects or calling any methods on objects in the Python.Runtime namespace. The only exception is PythonEngine.Initialize, which may be called without first calling AcquireLock. Each call to AcquireLock must be matched by a corresponding call to ReleaseLock, passing the token obtained from AcquireLock. For more information, see the "Extending and Embedding" section of the Python documentation on www.python.org.
public static AcquireLock ( ) : IntPtr
Результат System.IntPtr

BeginAllowThreads() публичный статический Метод

BeginAllowThreads Method
Release the Python global interpreter lock to allow other threads to run. This is equivalent to the Py_BEGIN_ALLOW_THREADS macro provided by the C Python API. For more information, see the "Extending and Embedding" section of the Python documentation on www.python.org.
public static BeginAllowThreads ( ) : IntPtr
Результат System.IntPtr

EndAllowThreads() публичный статический Метод

EndAllowThreads Method
Re-aquire the Python global interpreter lock for the current thread. This is equivalent to the Py_END_ALLOW_THREADS macro provided by the C Python API. For more information, see the "Extending and Embedding" section of the Python documentation on www.python.org.
public static EndAllowThreads ( IntPtr ts ) : void
ts System.IntPtr
Результат void

ImportModule() публичный статический Метод

ImportModule Method
Given a fully-qualified module or package name, import the module and return the resulting module object as a PyObject or null if an exception is raised.
public static ImportModule ( string name ) : PyObject
name string
Результат PyObject

InitExt() публичный статический Метод

public static InitExt ( ) : IntPtr
Результат System.IntPtr

InitExt() публичный статический Метод

public static InitExt ( ) : void
Результат void

Initialize() публичный статический Метод

Initialize Method
Initialize the Python runtime. It is safe to call this method more than once, though initialization will only happen on the first call. It is *not* necessary to hold the Python global interpreter lock (GIL) to call this method.
public static Initialize ( ) : void
Результат void

ModuleFromString() публичный статический Метод

ModuleFromString Method
Given a string module name and a string containing Python code, execute the code in and return a module of the given name.
public static ModuleFromString ( string name, string code ) : PyObject
name string
code string
Результат PyObject

ReleaseLock() публичный статический Метод

ReleaseLock Method
Release the Python global interpreter lock using a token obtained from a previous call to AcquireLock. For more information, see the "Extending and Embedding" section of the Python documentation on www.python.org.
public static ReleaseLock ( IntPtr gs ) : void
gs System.IntPtr
Результат void

ReloadModule() публичный статический Метод

ReloadModule Method
Given a PyObject representing a previously loaded module, reload the module.
public static ReloadModule ( PyObject module ) : PyObject
module PyObject
Результат PyObject

RunSimpleString() публичный статический Метод

public static RunSimpleString ( string code ) : int
code string
Результат int

RunString() публичный статический Метод

RunString Method
Run a string containing Python code. Returns the result of executing the code string as a PyObject instance, or null if an exception was raised.
public static RunString ( string code ) : PyObject
code string
Результат PyObject

RunString() публичный статический Метод

public static RunString ( string code, IntPtr globals, IntPtr locals ) : PyObject
code string
globals System.IntPtr
locals System.IntPtr
Результат PyObject

Shutdown() публичный статический Метод

Shutdown Method
Shutdown and release resources held by the Python runtime. The Python runtime can no longer be used in the current process after calling the Shutdown method.
public static Shutdown ( ) : void
Результат void