Skip to content

Commit

Permalink
Acquire the GIL when invoking callbacks (#431)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
azeey authored Aug 24, 2023
1 parent d888517 commit e176237
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions python/src/transport/_gz_transport_pybind11.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e176237

Please sign in to comment.