MCPcopy Create free account
hub / github.com/rabbitstack/fibratus / Initialize

Function Initialize

pkg/filament/cpython/interpreter.go:45–67  ·  view source on GitHub ↗

Initialize initializes the Python interpreter and its global interpreter lock (GIL).

()

Source from the content-addressed store, hash-verified

43
44// Initialize initializes the Python interpreter and its global interpreter lock (GIL).
45func Initialize() error {
46 if C.Py_IsInitialized() == 0 {
47 // initialize the interpreter without signal handlers
48 C.Py_InitializeEx(0)
49 }
50 if C.Py_IsInitialized() == 0 {
51 return ErrPyInit
52 }
53 if C.PyEval_ThreadsInitialized() == 0 {
54 C.PyEval_InitThreads()
55 }
56 if C.PyEval_ThreadsInitialized() == 0 {
57 return ErrGILInit
58 }
59 // this calls into PyDateTime_IMPORT macro to initialize the PyDateTimeAPI
60 C.Py_DateTimeImport()
61
62 if err := initializeIPFnAndClasses(); err != nil {
63 log.Warn(err)
64 }
65
66 return nil
67}
68
69// Finalize undos all initializations made by Initialize() and subsequent use of Python/C API functions,
70// and destroys all sub-interpreters that were created and not yet destroyed since the last call to Initialize().

Callers 9

TestProduceEventDictFunction · 0.92
NewFunction · 0.92
TestGILLockFunction · 0.85
TestGILUnlockFunction · 0.85
TestInitializeFunction · 0.85
TestNewModuleFunction · 0.85
TestModuleRegisterFnFunction · 0.85

Calls 1

initializeIPFnAndClassesFunction · 0.85

Tested by 8

TestProduceEventDictFunction · 0.74
TestGILLockFunction · 0.68
TestGILUnlockFunction · 0.68
TestInitializeFunction · 0.68
TestNewModuleFunction · 0.68
TestModuleRegisterFnFunction · 0.68