Skip to content

Commit

Permalink
Fix releasing GIL (#741)
Browse files Browse the repository at this point in the history
  • Loading branch information
csukuangfj authored Apr 8, 2024
1 parent 6fb8ced commit 6b3d2b8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
13 changes: 2 additions & 11 deletions sherpa-onnx/python/csrc/offline-stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,8 @@ void PybindOfflineStream(py::module *m) {
py::class_<PyClass>(*m, "OfflineStream")
.def(
"accept_waveform",
[](PyClass &self, float sample_rate, py::array_t<float> waveform) {
#if 0
auto report_gil_status = []() {
auto is_gil_held = false;
if (auto tstate = py::detail::get_thread_state_unchecked())
is_gil_held = (tstate == PyGILState_GetThisThreadState());

return is_gil_held ? "GIL held" : "GIL released";
};
std::cout << report_gil_status() << "\n";
#endif
[](PyClass &self, float sample_rate,
const std::vector<float> &waveform) {
self.AcceptWaveform(sample_rate, waveform.data(), waveform.size());
},
py::arg("sample_rate"), py::arg("waveform"), kAcceptWaveformUsage,
Expand Down
3 changes: 2 additions & 1 deletion sherpa-onnx/python/csrc/online-stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ void PybindOnlineStream(py::module *m) {
py::class_<PyClass>(*m, "OnlineStream")
.def(
"accept_waveform",
[](PyClass &self, float sample_rate, py::array_t<float> waveform) {
[](PyClass &self, float sample_rate,
const std::vector<float> &waveform) {
self.AcceptWaveform(sample_rate, waveform.data(), waveform.size());
},
py::arg("sample_rate"), py::arg("waveform"), kAcceptWaveformUsage,
Expand Down

0 comments on commit 6b3d2b8

Please sign in to comment.