[Stackless] unexpected tasklet & channel behaviour

Christian Tismer tismer at stackless.com
Wed Nov 1 11:01:39 CET 2006

Richard Tew wrote:

> I thought I was repeating a description you posted of how
> tasklet.run works :-)  But this is what I mean by it, which
> seems to meet the description:

Maybe I posted crap?
tasklet.run makes sure that that tasklet
runs. It is not responsible for anything,
like causing another tasklet to run.

>>>> def f(n):
> ...     while True:
> ...             print n
> ...             stackless.schedule()
> ...
>>>> t1 = stackless.tasklet(f)(1)
>>>> t2 = stackless.tasklet(f)(2)
>>>> t3 = stackless.tasklet(f)(3)
>>>> t1.run()
> 1
> 2
> 3
>>>> t1.run()
> 1
> 2
> 3
> I have wanted the ability to just run one tasklet in the past, but
> could not see how to do it cleanly.  So what I would do, and this
> was in fix to the tasklet killing on interpreter exit, was to place
> the tasklet I wanted to run before the current one, then to run
> the one I wanted to be run.. and it did the job to fix the bug
> that was present there.
> Anyway, I think most people expect tasklet.run to just run one
> tasklet and I think it would be a worthwhile change to make.

Well, I never found a clean way to run exactly one tasklet,
and I think it is not really possible. Collaborative
solutions like yours can of course work. But I cannot
imagine how we should get complete control over a tasklet
in a general way.
I agree that tasklet.run is promising something that does not
Stackless was not designed to run a specific tasklet, it was
more like letting things happen using the round-robin
approach. Maybe a coroutine interface would be more appropriate
to specify what a run() should do?

ciao - chris
Christian Tismer             :^)   <mailto:tismer at stackless.com>
tismerysoft GmbH             :     Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9A     :    *Starship* http://starship.python.net/
14109 Berlin                 :     PGP key -> http://wwwkeys.pgp.net/
work +49 30 802 86 56  mobile +49 173 24 18 776  fax +49 30 80 90 57 05
PGP 0x57F3BF04       9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
      whom do you want to sponsor today?   http://www.stackless.com/

Stackless mailing list
Stackless at stackless.com

More information about the Stackless mailing list