PythonProxyNotificationHandler::OnEventGenericHook acquires the Python GIL before executing (#3904)
- Protected python execution of OnEventGenericHook by trying to lock the GIL and show a descriptive error when it was not possible to lock. - Improved mechanism to lock python mutex and GIL in PhytonSystemComponent. Acquiring/releasing GIL once per thread. - Added unit test to verify errors are fired when trying to execute OnEventGenericHook from another thread (as it should not able to acquire the GIL). - Improved python threading tests to actually using python buses. Signed-off-by: moraaar moraaar@amazon.com
This commit is contained in:
@@ -48,6 +48,7 @@ namespace EditorPythonBindings
|
||||
bool IsPythonActive() override;
|
||||
void WaitForInitialization() override;
|
||||
void ExecuteWithLock(AZStd::function<void()> executionCallback) override;
|
||||
bool TryExecuteWithLock(AZStd::function<void()> executionCallback) override;
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
@@ -60,11 +61,13 @@ namespace EditorPythonBindings
|
||||
|
||||
private:
|
||||
class SymbolLogHelper;
|
||||
class PythonGILScopedLock;
|
||||
|
||||
// handle multiple Python initializers and threads
|
||||
AZStd::atomic_int m_initalizeWaiterCount {0};
|
||||
AZStd::semaphore m_initalizeWaiter;
|
||||
AZStd::recursive_mutex m_lock;
|
||||
int m_lockRecursiveCounter = 0;
|
||||
AZStd::shared_ptr<SymbolLogHelper> m_symbolLogHelper;
|
||||
|
||||
enum class Result
|
||||
|
||||
Reference in New Issue
Block a user