MCPcopy Create free account
hub / github.com/LBANN/lbann / finalize

Function finalize

src/utils/python.cpp:72–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70}
71
72void finalize()
73{
74
75 // Thread-safe finalization with double-checked locking pattern
76 if (is_active()) {
77 static std::mutex m;
78 std::lock_guard<std::mutex> lock(m);
79 if (is_active()) {
80
81 // Take GIL and finalize Python session
82 if (init_thread_state != nullptr) {
83 PyEval_RestoreThread(init_thread_state);
84 init_thread_state = nullptr;
85 }
86 Py_Finalize();
87
88 // Check that Python session has been finalized
89 if (is_active()) {
90 LBANN_WARNING("error finalizing embedded Python session");
91 }
92 }
93 }
94}
95
96bool is_active() { return Py_IsInitialized(); }
97

Callers 8

finalize_lbannMethod · 0.50
finalizeMethod · 0.50
python_test.cppFile · 0.50
mainFunction · 0.50
mainFunction · 0.50
mainFunction · 0.50
mainFunction · 0.50
parseMethod · 0.50

Calls 1

is_activeFunction · 0.85

Tested by 4

mainFunction · 0.40
mainFunction · 0.40
mainFunction · 0.40
mainFunction · 0.40