We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7508b87 commit 0f5db1aCopy full SHA for 0f5db1a
1 file changed
xbmc/interfaces/python/XBPython.cpp
@@ -57,7 +57,13 @@ XBPython::~XBPython()
57
#if PY_VERSION_HEX >= 0x03070000
58
if (Py_IsInitialized())
59
{
60
+ // Switch to the main interpreter thread before finalizing
61
PyThreadState_Swap(PyInterpreterState_ThreadHead(PyInterpreterState_Main()));
62
+
63
+ // Clear all loaded modules to prevent circular references
64
+ PyObject* modules = PyImport_GetModuleDict();
65
+ PyDict_Clear(modules);
66
67
Py_Finalize();
68
}
69
#endif
0 commit comments