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:
@@ -70,8 +70,12 @@ namespace AzToolsFramework
|
||||
//! Determines if the caller needs to wait for the Python VM to initialize (non-main thread only)
|
||||
virtual void WaitForInitialization() {}
|
||||
|
||||
//! Acquires the Python global interpreter lock (GIL) and executed the callback
|
||||
//! Acquires the Python global interpreter lock (GIL) and execute the callback
|
||||
virtual void ExecuteWithLock(AZStd::function<void()> executionCallback) = 0;
|
||||
|
||||
//! Tries to acquire the Python global interpreter lock (GIL) and execute the callback.
|
||||
//! @return Whether it was able to lock the mutex or not.
|
||||
virtual bool TryExecuteWithLock(AZStd::function<void()> executionCallback) = 0;
|
||||
};
|
||||
|
||||
//! A bus to handle post notifications to the console views of Python output
|
||||
|
||||
Reference in New Issue
Block a user