diff --git a/Code/Tools/ProjectManager/Source/PythonBindings.cpp b/Code/Tools/ProjectManager/Source/PythonBindings.cpp index 7158bfefb7..1a3e30f99f 100644 --- a/Code/Tools/ProjectManager/Source/PythonBindings.cpp +++ b/Code/Tools/ProjectManager/Source/PythonBindings.cpp @@ -313,33 +313,38 @@ namespace O3DE::ProjectManager bool PythonBindings::RegisterThisEngine() { - bool registerThis = true; - - // check current engine path against all other registered engines - // to see if we are already registered - auto allEngines = m_registration.attr("get_engines")(); - if (pybind11::isinstance(allEngines)) - { - for (const auto& engine : allEngines) + bool registrationResult = true; // already registered is considered successful + bool pythonResult = ExecuteWithLock( + [&] { - AZ::IO::FixedMaxPath enginePath(Py_To_String(engine["path"])); - if (enginePath.Compare(m_enginePath) == 0) + bool registerThis = true; + + // check current engine path against all other registered engines + // to see if we are already registered + auto allEngines = m_registration.attr("get_engines")(); + if (pybind11::isinstance(allEngines)) { - registerThis = false; - break; + for (const auto& engine : allEngines) + { + AZ::IO::FixedMaxPath enginePath(Py_To_String(engine["path"])); + if (enginePath.Compare(m_enginePath) == 0) + { + registerThis = false; + break; + } + } } - } - } - bool result = true; - if (registerThis) - { - auto registrationResult = m_registration.attr("register")(m_enginePath.c_str()); - result = (registrationResult.cast() == 0); - } + if (registerThis) + { + auto result = m_registration.attr("register")(m_enginePath.c_str()); + registrationResult = (result.cast() == 0); + } + }); - AZ_Assert(result, "Registration of this engine failed!"); - return result; + bool finalResult = (registrationResult && pythonResult); + AZ_Assert(finalResult, "Registration of this engine failed!"); + return finalResult; } bool PythonBindings::ExecuteWithLock(AZStd::function executionCallback)