Skip to content

Commit

Permalink
Fit gil lock for new version of pybind11
Browse files Browse the repository at this point in the history
  • Loading branch information
taoboyang committed Dec 28, 2024
1 parent fb571d6 commit 0384492
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion bmf/engine/c_engine/src/loader/py_module_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ class PyModuleFactory : public ModuleFactoryI {

std::shared_ptr<Module> make(int32_t node_id,
const JsonParam &json_param) override {
py::gil_scoped_acquire gil;
auto [module_cls, _] = factory_();
return std::make_shared<bmf_sdk::PyModule>(module_cls, node_id,
json_param);
Expand Down Expand Up @@ -263,7 +264,6 @@ bmf_import_py_module(const char *module_path, const char *module,
std::string cls_s(cls);
std::string register_info_func = "register_" + cls_s + "_info";
auto module_factory = [=]() -> std::tuple<py::object, py::object> {
py::gil_scoped_acquire gil;
auto py_module = py::module_::import(temp_module_name.c_str());
auto module_cls = py_module.attr(cls_s.c_str());
py::object module_info_register = py::none();
Expand All @@ -273,6 +273,7 @@ bmf_import_py_module(const char *module_path, const char *module,
}
return std::make_tuple(module_cls, module_info_register);
};


return new bmf_sdk::PyModuleFactory(module_factory);
} catch (std::exception &e) {
Expand Down
4 changes: 2 additions & 2 deletions bmf/engine/connector/src/connector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ BMFGraph::BMFGraph(const std::string &graph_config, bool is_path,
throw std::logic_error("Trying to bind an unexisted callback.");
callback_bindings[nd.id]->add_callback(
cb.first,
*internal::ConnectorMapping::ModuleCallbackInstanceMapping()
.get(cb.second));
std::move(*internal::ConnectorMapping::ModuleCallbackInstanceMapping()
.get(cb.second)));
}
}

Expand Down

0 comments on commit 0384492

Please sign in to comment.