[Stackless] Stackless Embedding/Extending & Threading Questions
richard.m.tew at gmail.com
Mon Mar 26 10:38:06 CEST 2007
On 3/26/07, Benjamin Tolputt <bjt at pmp.com.au> wrote:
> The issue comes from the multi-threading issues above. Firstly, to my
> understanding Boost Python integration is not by default multi-thread
> safe (there is apparently a method to make it so, but it is not included
> in the official distribution). As such, the easiest method I know to
> extend/embed Python & C++ is out the window. What methods do users on
> this list use to extend/embed their native code with/in Stackless?
CCP currently uses a custom method but we are moving to Boost Python.
We ignore the thread safe problems which exist with both solutions.
But it isn't really a problem as we run all our Python logic in the main thread
and Python is never used to deal with the other threads.
> Finally, given the cooperative nature of Stackless, I am not sure if
> there is a Stackless method of passing information between threads such
> that each thread can continue running. I have looked at the examples on
> the wiki, but the code samples indicate that either a) there is to be
The code samples are not intended to be used as documentation :-)
At least not the ones I wrote. In most cases they were written to
illustrate that something was possible with the expectation the
user would adapt it to suit their Stackless environment.
> only one thread running to make Stackless safe or b) one has to make the
Multiple Python threads running in Stackless should work fine.
> tasklet atomic & use "standard" threading classes/code to send
> information between Python threads. Is this correct or am I missing
> something fundamental?
Well, you want to pass information between threads without
blocking. In this case I would use the Queue class and its nowait
methods to do so. And making the tasklet atomic doesn't come
into it in that case because you are not blocking the tasklet
in the thread you are running the scheduler on anyway.
Hope this helps,
Stackless mailing list
Stackless at stackless.com
More information about the Stackless