More GIL releases while possibly waiting for a lock. Improves throughput, when also PyIndataHandlers are running (in case of a recording, for example
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Anne de Jong 2023-06-20 17:16:56 +02:00
parent 4ca8866cb7
commit 8711c6c57d

View File

@ -139,8 +139,8 @@ public:
*/ */
void reset(const Daq *daq) { void reset(const Daq *daq) {
DEBUGTRACE_ENTER; DEBUGTRACE_ENTER;
py::gil_scoped_acquire acquire;
try { try {
py::gil_scoped_acquire acquire;
if (daq) { if (daq) {
reset_callback(daq); reset_callback(daq);
} else { } else {
@ -154,6 +154,9 @@ public:
/// Therefore, it is better to dive out and prevent undefined behaviour /// Therefore, it is better to dive out and prevent undefined behaviour
abort(); abort();
/* throw std::runtime_error(e.what()); */ /* throw std::runtime_error(e.what()); */
} catch (std::exception &e) {
cerr << "Caught unknown exception in reset callback:" << e.what() << endl;
abort();
} }
} }
@ -200,7 +203,8 @@ public:
cerr << "ERROR: Python callback does not return boolean value." << endl; cerr << "ERROR: Python callback does not return boolean value." << endl;
abort(); abort();
} catch (std::exception &e) { } catch (std::exception &e) {
cerr << "Caught unknown exception:" << e.what() << endl; cerr << "Caught unknown exception in Python callback:" << e.what()
<< endl;
abort(); abort();
} }
} }
@ -219,7 +223,11 @@ void init_datahandler(py::module &m) {
ppm.def(py::init<SmgrHandle>()); ppm.def(py::init<SmgrHandle>());
ppm.def("getCurrentValue", [](const PPMHandler &ppm) { ppm.def("getCurrentValue", [](const PPMHandler &ppm) {
std::tuple<vd, arma::uvec> tp = ppm.getCurrentValue(); std::tuple<vd, arma::uvec> tp;
{
py::gil_scoped_release release;
tp = ppm.getCurrentValue();
}
return py::make_tuple(ColToNpy<d>(std::get<0>(tp)), return py::make_tuple(ColToNpy<d>(std::get<0>(tp)),
ColToNpy<arma::uword>(std::get<1>(tp))); ColToNpy<arma::uword>(std::get<1>(tp)));
@ -230,7 +238,11 @@ void init_datahandler(py::module &m) {
clip.def(py::init<SmgrHandle>()); clip.def(py::init<SmgrHandle>());
clip.def("getCurrentValue", [](const ClipHandler &clip) { clip.def("getCurrentValue", [](const ClipHandler &clip) {
arma::uvec cval = clip.getCurrentValue(); arma::uvec cval;
{
py::gil_scoped_release release;
cval = clip.getCurrentValue();
}
return ColToNpy<arma::uword>(cval); // something goes wrong here return ColToNpy<arma::uword>(cval); // something goes wrong here
}); });
@ -258,7 +270,11 @@ void init_datahandler(py::module &m) {
); );
rtaps.def("getCurrentValue", [](RtAps &rt) { rtaps.def("getCurrentValue", [](RtAps &rt) {
ccube val = rt.getCurrentValue(); ccube val;
{
py::gil_scoped_release release;
val = rt.getCurrentValue();
}
return CubeToNpy<c>(val); return CubeToNpy<c>(val);
}); });
@ -272,7 +288,11 @@ void init_datahandler(py::module &m) {
>()); >());
rtsv.def("getCurrentValue", [](RtSignalViewer &rt) { rtsv.def("getCurrentValue", [](RtSignalViewer &rt) {
dmat val = rt.getCurrentValue(); dmat val;
{
py::gil_scoped_release release;
val = rt.getCurrentValue();
}
return MatToNpy<d>(val); return MatToNpy<d>(val);
}); });
} }