[Stackless] channels and StopIteration

Richard Tew richard.m.tew at gmail.com
Thu Apr 12 05:18:05 CEST 2012

On Thu, Apr 12, 2012 at 1:49 AM, Kristján Valur Jónsson
<kristjan at ccpgames.com> wrote:
> Channels objey the iterator protocol.  calling channel.close() will raise
> the StopIteration exception from the channel.__next__ method.
> But, calling channel.close() from the receiving end will also cause this
> same exception to be raised when someone wants to call channel.send().
> Now, I wonder if a more appropriate exception for the send() call wouldn‘t
> be GeneratorExit()?    This is what the generator yield(foo) statement
> raises when the generator is closed, and it seems logical that this should
> be the exception raised when someone tries to send to a closed channel.

Let's say there is existing code out there that expects the old
behaviour, this would of course break that code.  And on the other
hand, I'm not sure that something which is not a generator raising
generator-related exceptions is an appropriate change - but then we
could make a Stackless-specific subclass which was more specific.

Is breaking backwards compatibility worth the gain?


More information about the Stackless mailing list