title: Working with concurrency and boost::python callbacks
body: <p>I want to pass a callback into a c function, and then later call it while not holding the GIL. If I hold the GIL the whole time, then I'm unable to have concurrency in my program.</p>
  <p>One option I tried is calling <code>PyGILState_Ensure</code> before-hand (<a href="https://stackoverflow.com/questions/8545831/boostpython-and-callback-driven-execution">boost::python and callback driven execution</a>), but it seems to lead to dead-lock. Does anyone have any ideas for how I can invoke the callback?</p>
  <p>My code to run the callback:</p>
  <pre><code>using namespace boost::python;
  
  PyObject* onResponseComplete_; // initialized somewhere
  call&lt;void&gt;(onResponseComplete_);
  </code></pre>
  <p>And I'm using a <code>GILReleaser</code> for concurrency. If I don't release the GIL with the following, I have no issues.</p>
  <pre><code>GILReleaser::GILReleaser() {
    state_ = PyEval_SaveThread();
  }
  
  GILReleaser::~GILReleaser() {
    PyEval_RestoreThread(state_);
  }
  </code></pre>