[Stackless] Writing a New API Call - getNextScheduled()

Richard Tew richard.m.tew at gmail.com
Mon Apr 7 18:04:21 CEST 2008

On Mon, Apr 7, 2008 at 11:35 AM, Andrew Francis <andrewfr_ice at yahoo.com> wrote:
>  Often I would like to know, all other things being
>  equal,  what is the next tasklet to be scheduled. Also
>  I would like to know a bit more about Stackless under
>  the hood. The scheduled property is computed. I would
>  like to know how I would go about writing this
>  function so I could test out its usefulness.

You should try introspection some time Andrew.

>>> def f(n): print n
>>> stackless.tasklet(f)(1)
<stackless.tasklet object at 0x00B02070>
>>> t1 = _
>>> t2 = stackless.tasklet(f)(2)
>>> dir(t1)
['__call__', '__class__', '__delattr__', '__doc__', '__getattribute__', '__hash_
_', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr_
_', '__setattr__', '__setstate__', '__slots__', '__str__', '_channel', 'alive',
'atomic', 'become', 'bind', 'block_trap', 'blocked', 'capture', 'cstate', 'frame
', 'ignore_nesting', 'insert', 'is_current', 'is_main', 'kill', 'nesting_level',
 'next', 'paused', 'prev', 'raise_exception', 'recursion_depth', 'remove', 'rest
orable', 'run', 'scheduled', 'set_atomic', 'set_ignore_nesting', 'setup', 'tempv
al', 'thread_id']
>>> t2.next
<stackless.tasklet object at 0x00AA38B0>
>>> t1.next is t2

So.. one would assume that:

stackless.getcurrent().next would be your huckleberry.

>>> stackless.getcurrent().next is t1


More information about the Stackless mailing list