8000 Python: Fix hang at application shutdown · xbmc/xbmc@0f5db1a · GitHub
[go: up one dir, main page]

Skip to content

Commit 0f5db1a

Browse files
committed
Python: Fix hang at application shutdown
1 parent 7508b87 commit 0f5db1a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

xbmc/interfaces/python/XBPython.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,13 @@ XBPython::~XBPython()
5757
#if PY_VERSION_HEX >= 0x03070000
5858
if (Py_IsInitialized())
5959
{
60+
// Switch to the main interpreter thread before finalizing
6061
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+
6167
Py_Finalize();
6268
}
6369
#endif

0 commit comments

Comments
 (0)
0