Ok, I just found this: <a href="http://www.boost.org/libs/python/doc/v2/faq.html#threadsupport">http://www.boost.org/libs/python/doc/v2/faq.html#threadsupport</a><br><br>I seems to be saying that I can not do what I want with out patching Boost::Python (or does this only apply to multiple interpretors? )
<br>Is this still true (please tell me it&#39;s been fixed)?<br>if so, where can I get this patch and how do I apply it?<br><br>I asked about multi-threading and boost python in on this list a while ago, and got no answer. I took this a a &quot;go ahead, no problems&quot;. If I am being an idiot, could you tell me so? Just flame away at me so I know I&#39;ve been stupid.&nbsp; A lot of people here actually know what they are doing. I do not have that luxury.&nbsp; I am finding boost python extremely complex and non-intuitive.&nbsp; There is also a lack of good documentation (example code is nice to have, but does not constitute proper documentation all by itself).
<br><br><br><br><br><br>On 10/30/07, Matthew Scouten &lt;<a href="mailto:matthew.scouten@gmail.com">matthew.scouten@gmail.com</a>&gt; wrote:<br>&gt; This is diving me nuts. I need to triple check an assumption.<br>&gt; <br>
&gt; I am *extending* python using Boost::Python, by wrapping a complex c++<br>&gt; library that was written years ago with no thought of future use in<br>&gt; python.<br>&gt; <br>&gt; The library works by a system of callouts and callbacks with extensive
<br>&gt; multithreading.<br>&gt; <br>&gt; There are a number of minor worker threads in the background, but<br>&gt; [ASSUMPTION ONE:] this should not matter because they never need to<br>&gt; use data or call code that is known to the interpretor.
<br>&gt; <br>&gt; There is also a callback thread on which the callbacks are called.<br>&gt; This is NOT a python thread, an interpretor thread, or ANY other<br>&gt; special kind of thread. It was not started through the C/Python API.
<br>&gt; It is a system thread started through the WIN32 API in the byzantine<br>&gt; depths of the library. It has not been introduced to the interpretor<br>&gt; in any way.<br>&gt; <br>&gt; ASSUMPTION TWO:<br>&gt; I can have that thread call into python code by using the
<br>&gt; PyGILState_Ensure &amp; PyGILState_Release pair of functions as described<br>&gt; in <a href="http://www.python.org/dev/peps/pep-0311/">http://www.python.org/dev/peps/pep-0311/</a> and<br>&gt; <a href="http://docs.python.org/api/threads.html">
http://docs.python.org/api/threads.html</a> to acquire the Global<br>&gt; Interpretor Lock.<br>&gt; <br>&gt; (Actually:&nbsp;&nbsp;I am using Resource Acquisition Is Initialization idiom<br>&gt; with the following simple class:<br>
&gt; <br>&gt; class callback<br>&gt; {<br>&gt; public:<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; inline callback()<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; state = PyGILState_Ensure();<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&gt; <br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; inline ~callback()
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PyGILState_Release(state);<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&gt; <br>&gt; private:<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PyGILState_STATE state;<br>&gt; };<br>&gt; <br>&gt; This may be ASSUMPTION THREE)<br>&gt; <br>
&gt; Are my assumptions valid?<br>&gt; <br>&gt; This may seem like a simple question that I should be googling for,<br>&gt; but like I said I am triple checking some assumptions. I have been<br>&gt; trying to debug the same extremely bizarre&nbsp;&nbsp;problem for a couple of
<br>&gt; days now and it only shows up in the asynchronous callbacks.<br>&gt; <br>