def doRead(self):
        """
        Called when my socket is ready for reading.
        """
        read = 0
        while read < self.maxThroughput:
            try:
                data = self._system.read(self._fileno, self.maxPacketSize)
            except EnvironmentError as e:
                if e.errno in (errno.EWOULDBLOCK, errno.EAGAIN, errno.EINTR):
                    return
                else:
                    raise
            except:
                raise
            read += len(data)
            # TODO pkt.isPartial()?
            try:
                self.protocol.datagramReceived(data, partial=0)
            except:
                cls = fullyQualifiedName(self.protocol.__class__)
                log.err(
                    None,
                    "Unhandled exception from %s.datagramReceived" % (cls,))

        Called when my socket is ready for reading.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/pair/tuntap.py