On Sun, 14 Oct 2012 20:12:04 +1300 Greg Ewing email@example.com wrote:
So the implementation of sock.async_read() is going to have to create another Future to handle waiting for the socket to become ready. But then the outer Future is an unnecessary complication, because you could get the same effect by defining
def async_read(self, length): yield future_to_wait_for_fd(self.fd) return os.read(self.fd, length)
read() may fail even if select() returned successfully. See http://bugs.python.org/issue9090
What this means is that your select-style event loop should probably also handle actually reading the data. Besides, this will make its API more easily ported to something like IOCP.