Thanks Richard! Your solution definitely helped me solving this problem. :)
Instead of having to compiling the Python code in the C string, I actually had the leisure to define RunFunctionAndGetResult (well, I changed the name actually :)) inside one of our utility python source file, and from C code I just retrieve the respective PyObject reference, which is then in turn wrapped into a tasklet on the C side! For channel stuff, I had to use PyChannel_GetQueue to poll the channel if any function running as a tasklet has finished, so they got blocked on it due to trying to put the return value on the channel, since on the C side, everything must not block, and C code would *better* not participate in Stackless tasklet scheduling, even though I know (heard) Stackless can swap C stack perfectly as well, but please, don't block my C code. :) From: [email protected] [mailto:[email protected]] On Behalf Of Andrew Tutt Sent: Wednesday, June 23, 2010 3:13 PM To: The Stackless Python Mailing List Subject: Re: [Stackless] Retrieving the Return Value of a Stackless Python Tasklet Bound Function? The simplest way to do this would be to define the wrapping Python function code in C as a string, and to compile it into a function object that you can run as a tasklet. An example Python function follows, the C part I leave to you. e.g. def RunFunctionAndGetResult(chan, func, *args, **kwargs): chan.send(func(*args, **kwargs)) That was precisely the suggestion I would have made, but I was not sure it would be right. Gives me a bit more confidence when it comes to answering future questions! On Tue, Jun 22, 2010 at 11:16 PM, Richard Tew <[email protected]<mailto:[email protected]>> wrote: On Tue, Jun 22, 2010 at 11:37 PM, Lin Luo <[email protected]<mailto:[email protected]>> wrote: > the caller. But I have yet to see a way to retrieve the return value of the > bound callable running as a tasklet. I do not know that there is one. > important return value to be used later. It seems that writing such a > Micromanaging function on the C side is not very feasible, since I haven't The simplest way to do this would be to define the wrapping Python function code in C as a string, and to compile it into a function object that you can run as a tasklet. An example Python function follows, the C part I leave to you. e.g. def RunFunctionAndGetResult(chan, func, *args, **kwargs): chan.send(func(*args, **kwargs)) Cheers, Richard. _______________________________________________ Stackless mailing list [email protected]<mailto:[email protected]> http://www.stackless.com/mailman/listinfo/stackless
_______________________________________________ Stackless mailing list [email protected] http://www.stackless.com/mailman/listinfo/stackless
