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

Stephan Diehl stephan.diehl at gmx.net
Mon Apr 7 18:23:23 CEST 2008


Andrew,

and since we are at it, don't forget the stackless.set_schedule_callback 
function. Just run
>>> help(stackless.set_schedule_callback)
to get help on the callback function signature.

Cheers

Stephan

Am Montag, 7. April 2008 18:04:21 schrieb Richard Tew:
> 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
>
> True
>
>
> So.. one would assume that:
>
> stackless.getcurrent().next would be your huckleberry.
>
> >>> stackless.getcurrent().next is t1
>
> True
>
> Cheers,
> Richard.
>
> _______________________________________________
> Stackless mailing list
> Stackless at stackless.com
> http://www.stackless.com/mailman/listinfo/stackless






More information about the Stackless mailing list