c++ - How to wrap a message loop with callbacks using boost::python (keeping the GIL in mind) -


i want wrap existing c++ library involves blocking message loop , calling handler functions python using boost::python. e.g.:

import my_boostpython_lib  def my_handler_fn():     do_something()  md = my_boostpython_lib.message_dispatcher()  # calls c++ object method , blocks md.run_message_loop(my_handler_fn) 

calling python function c++ no problem message loop needs release gil since otherwise block whole python interpreter (see here, here , related boost ticket)

as stated here it's important lock gil again before calling python function.

in principle sounds comprehensible me wonder if there elegant solutions out there show how can done. e.g. nice if had modify boost::python wrapper (instead of altering library want wrap)

do know working example involves boost::python, callbacks using object oriented approach (and maybe blocking functions release gil) can copy best practices from?


Comments