Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fit gil lock for new version of pybind11 #166

Merged
merged 2 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
run: |
sudo apt update
sudo apt install -y make git pkg-config libssl-dev cmake binutils-dev libgoogle-glog-dev gcc g++ golang wget libgl1
sudo apt install -y python3.9 python3-dev python3-pip
sudo apt install -y python3.9 python3-dev python3-pip libsndfile1 libsndfile1-dev
sudo python3 -m pip install timeout_decorator numpy onnxruntime pytest opencv-python librosa
# The version of ffmpeg installed via apt is 4.2, but the current test results are based on version 4.4, so here we need to compile version 4.4 of ffmpeg from source code
#apt install -y ffmpeg libavcodec-dev libavdevice-dev libavfilter-dev libavformat-dev libavresample-dev libavutil-dev libpostproc-dev libswresample-dev libswscale-dev
Expand Down
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