On 13/08/10 16:13, Nick Coghlan wrote:
But the "yield" is also the point that allows the scheduler to throw in an exception to indicate that the socket has gone away and that the error should be propagated up the coroutine stack.
If by "gone away" you mean that the other end has been closed, that's already taken care of. The socket becomes ready to read, the coroutine wakes up, tries to read it and discovers the EOF condition for itself.
The same thing applies if anything happens to the socket that would cause an exception if you tried to read it. All the scheduler needs to do is notice that the socket is being reported as ready by select(). When the coroutine tries to deal with it, the exception will occur in that coroutine and be propagated within it.
I'm not saying that no scheduler will ever want to throw an exception into a coroutine, but it's not needed in this case.