[PEAK] Legacy code in events.Observable ?

Phillip J. Eby pje at telecommunity.com
Thu Nov 16 13:31:06 EST 2006


At 04:39 PM 11/16/2006 +0200, ilja wrote:
>Hi.
>
>I've recently was working with disabling/enabling events, and found one 
>strange thing in implementation of event buffering (when event source is 
>in `disabled` state).
>
>The `Observable._buffer` method contains strange code:
>{{{
>...
>     elif len(saved)>=len(self._callbacks):
>         raise ValueError("Can't buffer event", self, event)
>...
>}}}
>
>Does it have any purpose?
>And if Yes than why such limitations are applied?

It prevents buffer overruns.  See the 'overrunOK' attribute -- which 
defaults to True.  So, this code won't be used unless you set overrunOK to 
false (e.g. in Distributor and Broadcaster), meaning you don't want more 
events to accumulate in the buffer than you have callbacks registered for.

This is important for distributors and broadcasters, because you don't want 
to keep queueing events to a disabled source that has no listeners - the 
list would simply grow without bound.  Thus, the queue length is limited to 
having at most one more event than there are listeners.




More information about the PEAK mailing list