Release gil when compiling spec.
When compiling with threading, we will block the main thread anyways waiting for all threads to complete. PiperOrigin-RevId: 854230560 Change-Id: Ief689d381afaa3aacc5d712a8df0cb4b6762251c
This commit is contained in:
committed by
Copybara-Service
parent
45e164bf8f
commit
e37c2268a6
@@ -89,7 +89,12 @@ MjSpec::~MjSpec() { mj_deleteSpec(ptr); }
|
|||||||
|
|
||||||
raw::MjModel* MjSpec::Compile() {
|
raw::MjModel* MjSpec::Compile() {
|
||||||
if (assets.empty()) {
|
if (assets.empty()) {
|
||||||
auto m = mj_compile(ptr, 0);
|
raw::MjModel* m;
|
||||||
|
{
|
||||||
|
// Release GIL before calling mj_compile which may spawn threads
|
||||||
|
py::gil_scoped_release no_gil;
|
||||||
|
m = mj_compile(ptr, 0);
|
||||||
|
}
|
||||||
if (!m || mjs_isWarning(ptr)) {
|
if (!m || mjs_isWarning(ptr)) {
|
||||||
throw py::value_error(mjs_getError(ptr));
|
throw py::value_error(mjs_getError(ptr));
|
||||||
}
|
}
|
||||||
@@ -112,7 +117,13 @@ raw::MjModel* MjSpec::Compile() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto m = mj_compile(ptr, &vfs);
|
|
||||||
|
raw::MjModel* m;
|
||||||
|
{
|
||||||
|
// Release GIL before calling mj_compile which may spawn threads
|
||||||
|
py::gil_scoped_release no_gil;
|
||||||
|
m = mj_compile(ptr, &vfs);
|
||||||
|
}
|
||||||
mj_deleteVFS(&vfs);
|
mj_deleteVFS(&vfs);
|
||||||
if (!m || mjs_isWarning(ptr)) {
|
if (!m || mjs_isWarning(ptr)) {
|
||||||
throw py::value_error(mjs_getError(ptr));
|
throw py::value_error(mjs_getError(ptr));
|
||||||
|
|||||||
Reference in New Issue
Block a user