C# 클래스 Python.Runtime.PythonEngine

This class provides the public interface of the Python runtime.
파일 보기 프로젝트 열기: pythonnet/pythonnet 1 사용 예제들

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