producers[int(ind)] = stackless.tasklet(producer)(ind,sleeptime) this line will create a tasklet bound to the "producer" callable, bind it to (ind, sleeptime) and return it to the "producers" list. Setting up a tasklet simply returns the same tasklet object, exactly so that you can do the following: producers[int(ind)] = stackless.tasklet(producer) producers[int(ind)](ind, sleeptime)
in one line. There is no "return value" from the tasklet in play here. in short: stackless.tasklet.__call__(self, *args) returns self. K From: [email protected] [mailto:[email protected]] On Behalf Of A M Sent: 29. desember 2009 09:09 To: [email protected] Subject: [Stackless] Calling a tasklet with a return value with the C API After a few years of scouring the Internet for example code and viewing the very sparse documentation on the subject, I have been able to successfully utilize almost all aspects of the C API with regard to stackless python. I feel pretty comfortable with most all functions declared in stackless_api.h. However, there is one thing I cannot figure out and cannot find an example for anywhere: running a tasklet with the C API that returns a value. Take, for example, this python code from one of the stackless python examples online (http://stacklessexamples.googlecode.com/svn/trunk/examples/producerConsumerTextmode.py): ----------- def launch_p (ind,sleeptime): # Launches and initializes the producers lists producers.append(int(ind)) p_counter.append(0) producers[int(ind)] = stackless.tasklet(producer)(ind,sleeptime) ------------ The last line is the one that I have no idea how to recreate. Certainly, creating a tasklet, setting it up, and running it is trivial; however, I cannot for the life of me figure out how you would get a return value with the C API. My initial thought was perhaps the results are sent back on a 'channel'; however, I do not see any documentation that supports that, nor can I find any examples of it. Anyway, can anyone help me out with this? It's keeping me awake at night! If not, can someone give me a contact address for one of the developers of stackless that wrote the C API for it? Thanks Andy ps. By the way, does anyone know why this link indicates that it's the C/C++ API for stackless 2.6.4 but has none of the stackless functions within it? -> http://www.disinterest.org/resource/stackless/2.6.4-docs-html/c-api/index.html
_______________________________________________ Stackless mailing list [email protected] http://www.stackless.com/mailman/listinfo/stackless
