def _handle_read_event(self):
        """
        Handle a read event raised on the channel.
        """
        while True:
            try:
                sock, addr = self._socket_accept()
            except socket.error:
                log.exception("Exception raised by accept() on %r." % self)
                try:
                    sock.close()
                except socket.error:
                    pass
                return

            if sock is None:
                return

            if self.ssl_enabled:
                try:
                    sock.setblocking(False)
                    sock = ssl.wrap_socket(sock, **self._ssl_options)
                except ssl.SSLError as e:
                    self._safely_call(self.on_ssl_wrap_error, sock, addr, e)
                    continue

            self._safely_call(self.on_accept, sock, addr)
dataset/ETHPy150Open ecdavis/pants/pants/server.py/Server._handle_read_event/original