Fangjun Kuang
Committed by GitHub

Fix releasing GIL (#741)

@@ -53,17 +53,8 @@ void PybindOfflineStream(py::module *m) { @@ -53,17 +53,8 @@ void PybindOfflineStream(py::module *m) {
53 py::class_<PyClass>(*m, "OfflineStream") 53 py::class_<PyClass>(*m, "OfflineStream")
54 .def( 54 .def(
55 "accept_waveform", 55 "accept_waveform",
56 - [](PyClass &self, float sample_rate, py::array_t<float> waveform) {  
57 -#if 0  
58 - auto report_gil_status = []() {  
59 - auto is_gil_held = false;  
60 - if (auto tstate = py::detail::get_thread_state_unchecked())  
61 - is_gil_held = (tstate == PyGILState_GetThisThreadState());  
62 -  
63 - return is_gil_held ? "GIL held" : "GIL released";  
64 - };  
65 - std::cout << report_gil_status() << "\n";  
66 -#endif 56 + [](PyClass &self, float sample_rate,
  57 + const std::vector<float> &waveform) {
67 self.AcceptWaveform(sample_rate, waveform.data(), waveform.size()); 58 self.AcceptWaveform(sample_rate, waveform.data(), waveform.size());
68 }, 59 },
69 py::arg("sample_rate"), py::arg("waveform"), kAcceptWaveformUsage, 60 py::arg("sample_rate"), py::arg("waveform"), kAcceptWaveformUsage,
@@ -25,7 +25,8 @@ void PybindOnlineStream(py::module *m) { @@ -25,7 +25,8 @@ void PybindOnlineStream(py::module *m) {
25 py::class_<PyClass>(*m, "OnlineStream") 25 py::class_<PyClass>(*m, "OnlineStream")
26 .def( 26 .def(
27 "accept_waveform", 27 "accept_waveform",
28 - [](PyClass &self, float sample_rate, py::array_t<float> waveform) { 28 + [](PyClass &self, float sample_rate,
  29 + const std::vector<float> &waveform) {
29 self.AcceptWaveform(sample_rate, waveform.data(), waveform.size()); 30 self.AcceptWaveform(sample_rate, waveform.data(), waveform.size());
30 }, 31 },
31 py::arg("sample_rate"), py::arg("waveform"), kAcceptWaveformUsage, 32 py::arg("sample_rate"), py::arg("waveform"), kAcceptWaveformUsage,