If worried about doneness, maybe try and catch a 'no more data' or 'socket closed' exception then reraise as StopIteration.  might hide real errors though