Note that there are some explanatory texts on larger screens.

plurals
  1. PORetrieving the Return Value of a Stackless Python Tasklet Bound Function?
    primarykey
    data
    text
    <p>Stackless Experts,</p> <p>I have managed to create tasklets under Stackless Python (both from the Stackless and the C side).</p> <p>It seems to me that in order to create a tasklet in Stackless, you bind an arbitrary Python callable (function) to the tasklet (as well as the required parameters), so the bound callable would be run as a tasklet. However, an arbitrary callable might actually have a return value that's important to the caller. But I have yet to see a way to retrieve the return value of the bound callable running as a tasklet.</p> <p>On the pure Stackless Python side, I do see a usage idiom called Micromanaging, which wraps the original function with a managing function, which in turn <em>could</em> capture the return value of the original function and save it somewhere for use in some other context.</p> <p>Unfortunately, my special use case involves creating a tasklet from the C (C++) side, binding to a (potentially blocking) Python callable which has an 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 found a way to turn a C function into a PyObject callable dynamically (not involving module table initialization, etc.), and using static stateless C function (I would assume the prototype has to be PyObject* (PyObject*, PyObject*)) is generally a bad idea under C++ world anyways.</p> <p>The Stackless C API also seems not containing a proper function to retrieve the return value of a tasklet. Is it the only option that I have to write above mentioned Micromanaging function (<em>could</em> be stateful) in Python, and provide a way to retrieve the return value saved somewhere (in a stateful fashion, i.e. not using global variables)? Or there could be other options I could possibly explore?</p> <p>Thank you very much,</p> <p>Lin</p> <p>P.S. I understand that on the C and operating system level programming, the return value of a thread function is only meaningful for exit code, and thread functions would have a strict function prototype, i.e. C functions have to abide by some strict rules to become runnable as/by a thread. And now we are talking about Python :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload