Created
August 28, 2020 23:49
-
-
Save asavah/38ddbe6a45dd5024b8a832d01936e439 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/xbmc/interfaces/python/PythonInvoker.cpp b/xbmc/interfaces/python/PythonInvoker.cpp | |
index c559723a16..54d78ce374 100644 | |
--- a/xbmc/interfaces/python/PythonInvoker.cpp | |
+++ b/xbmc/interfaces/python/PythonInvoker.cpp | |
@@ -588,8 +588,6 @@ void CPythonInvoker::onExecutionDone() | |
// unregister the language hook | |
m_languageHook->UnregisterMe(); | |
- PyEval_ReleaseLock(); | |
- | |
// set stopped event - this allows ::stop to run and kill remaining threads | |
// this event has to be fired without holding m_critical | |
// also the GIL (PyEval_AcquireLock) must not be held | |
@@ -605,8 +603,7 @@ void CPythonInvoker::onExecutionDone() | |
void CPythonInvoker::onExecutionFailed() | |
{ | |
- PyThreadState_Swap(NULL); | |
- PyEval_ReleaseLock(); | |
+ PyEval_SaveThread(); | |
setState(InvokerStateFailed); | |
CLog::Log(LOGERROR, "CPythonInvoker(%d, %s): abnormally terminating python thread", GetId(), m_sourceFile.c_str()); | |
diff --git a/xbmc/interfaces/python/XBPython.cpp b/xbmc/interfaces/python/XBPython.cpp | |
index 047896ba48..0bcf9ab733 100644 | |
--- a/xbmc/interfaces/python/XBPython.cpp | |
+++ b/xbmc/interfaces/python/XBPython.cpp | |
@@ -470,7 +470,7 @@ void XBPython::Finalize() | |
PyEval_AcquireThread(curTs); | |
Py_Finalize(); | |
- PyEval_ReleaseLock(); | |
+ PyEval_ReleaseThread(curTs); | |
} | |
#if !(defined(TARGET_DARWIN) || defined(TARGET_WINDOWS)) | |
@@ -663,6 +663,10 @@ void XBPython::OnExecutionEnded(ILanguageInvoker* invoker) | |
} | |
++it; | |
} | |
+ PyThreadState* curTs = (PyThreadState*)m_mainThreadState; | |
+ PyThreadState_Swap(curTs); | |
+ PyEval_ReleaseThread(curTs); | |
+ CLog::Log(LOGINFO, "Python XBPython::OnExecutionEnded GIL lock released"); | |
} | |
void XBPython::OnScriptFinalized(ILanguageInvoker *invoker) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment