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