[Stackless] Stackless API (Custom Scheduling)

Christian Tismer tismer at stackless.com
Thu Jan 29 22:45:51 CET 2004


Bob Ippolito wrote:

> On Jan 29, 2004, at 2:57 PM, Christian Tismer wrote:
> 
>> Hilmar V. Pétursson wrote:
>>
>>> As Chris points out we have used become() with great success, through 
>>> out the passed 3 years.
>>> There are ~200 reference to become() in our Stackless Python scripts 
>>> that make up the logic and rules of a ~35.000 player MMORPG world.
>>> We have had close to 7.000 players playing together in the same, 
>>> fully 3D simulated, shared universe, so even though semantics might 
>>> be unconventional, they sure do work once you align our mind to the 
>>> power of Stackless :-)
>>> Please don't take it out...
>>
>>
>> ...
>>
>> As we are at it:
>> What I *want* to take out is support for sending
>> exceptions to channels.
>> This was an early approach to kill somthing that's
>> waiting in a channel. I think this is no longer needed,
>> and it would clarify the code quite some bit.
>> Today, we have an explicit kill that can kill any
>> tasklet and even a cat. In summer 2002, I couldn't do that.
> 
> 
> I have actually used the exceptions on channels to send 
> KeyboardInterrupt to my "interpreter" tasklet.  The interpreter doesn't 
> have any idea that it's stackless, and I don't want to kill it, just 
> raise an exception.  I'm sure there are other uses for it as well, such 
> as in Twisted (if there was an error on your deferred, it can raise the 
> exception by that means).
> 
> I think we should keep it, unless you have a better idea.  I'm not sure 
> I want the sender of the exception to always have a direct reference to 
> the tasklet.

How about (untested):

class MyChannel(stackless.channel):
   def send_exception(self, klass, inst):
     t = self.queue
     t.raise_exception(klass, inst)

The only difference is that this simple implementation
will not block if there is no listener, but simply will
barf because self.queue is None. This can be enhanced.
I don't believe that the current built-in behavior is
what we want, too, since it acts like a time-bomb:
The exception-sender will be blocked until somebody
receives. If (s)he receives, the tasklet will continue,
and the receiver will get bombed. Tsz tzz tzz...

ciao - chris
-- 
Christian Tismer             :^)   <mailto:tismer at stackless.com>
Mission Impossible 5oftware  :     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 89 09 53 34  home +49 30 802 86 56  mobile +49 173 24 18 776
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
http://www.stackless.com/mailman/listinfo/stackless



More information about the Stackless mailing list