From e176237b215d613215763be70d2cd59c0c1b6b86 Mon Sep 17 00:00:00 2001 From: "Addisu Z. Taddese" Date: Thu, 24 Aug 2023 18:13:12 -0500 Subject: [PATCH] Acquire the GIL when invoking callbacks (#431) gz-transport callbacks are invoked from a separate thread so we need to acquire the GIL. Users such as gz-sim need to release the GIL regularly to ensure callbacks are serviced in a timely manner. Signed-off-by: Addisu Z. Taddese --- python/src/transport/_gz_transport_pybind11.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/python/src/transport/_gz_transport_pybind11.cc b/python/src/transport/_gz_transport_pybind11.cc index dc582c71c..0f8ac9422 100644 --- a/python/src/transport/_gz_transport_pybind11.cc +++ b/python/src/transport/_gz_transport_pybind11.cc @@ -282,6 +282,7 @@ PYBIND11_MODULE(BINDINGS_MODULE_NAME, m) { { auto _cb = [_callback](const char *_msgData, const size_t _size, const MessageInfo &_info){ + pybind11::gil_scoped_acquire acq; return _callback(py::bytes(_msgData, _size), _info); }; return _node.SubscribeRaw(_topic, _cb, _msgType, _opts);