[Stackless] Stackless Embedding/Extending & Threading Questions

Benjamin Tolputt bjt at pmp.com.au
Mon Mar 26 05:56:33 CEST 2007


I am looking at embedding & extending Stackless in a project where I 
think the ability to run many "stateless" tasks will be most beneficial 
(and the ability to develop on Win32 and deploy to Linux is also a big 
plus, but one not specific to Stackless Python).

As there is a significant amount of simple looping code (searching 
through large directed graphs), I was thinking of creating a native 
module that would perform said looping (with a maximum number of loops 
per call) returning either a solution or the intermediate state of the 
search to the python code (i.e. allowing Stackless to "be nice" and 
yield to other running tasklets). I do not see this being an issue, but 
provide it as background to my next question.

Given the number of intended simultaneous users, the number of requests 
I need this application to support, and the fact that the application 
will be deployed on a machine having quad-core processors (not my 
choice); I am designing the system to run multiple threads (one for the 
actual graph processing, another for saving/loading from the database, 
another to handle network connections/processing, etc). This is simply 
to utilise the processing power available, not because I don't think 
there is a better Stackless-centric method.

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?

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 
only one thread running to make Stackless safe or b) one has to make the 
tasklet atomic & use "standard" threading classes/code to send 
information between Python threads. Is this correct or am I missing 
something fundamental?

Regards,
B.J.Tolputt


_______________________________________________
Stackless mailing list
Stackless at stackless.com
http://www.stackless.com/mailman/listinfo/stackless



More information about the Stackless mailing list