def loop(self):
        sockets = [self.server]
        try:
            while self.active():
                try:
                    ready, _, _ = select.select(sockets, [], [], 0.1)
                except __HOLE__:
                    raise socket.error
                if not self.client:
                    if self.server in ready:
                        print('client connection')
                        self.client, addr = self.server.accept()
                        sockets = [self.client]
                        self.cmd('1', 'create')
                        for line in self.preload:
                            self.send(line)
                    else:
                        continue
                elif self.client in ready:
                    # we're willing to wait up to 1/120 of a second
                    # for a delete following an erase
                    # this and a big buffer prevent flickering.
                    data = self.client.recv(102400).decode('utf8')
                    if 'remove' in data and not 'insert' in data:
                        more, _, _ = select.select([self.client], [], [], 1.0 / 120)
                        if more:
                            data += self.client.recv(102400).decode('utf8')

                    # print('data:', data)
                    if data:
                        self.handle(data)
                    else:
                        break
        except socket.error:
            pass
        finally:
            self.close(disconnect=True)
dataset/ETHPy150Open lunixbochs/actualvim/vim.py/VimSocket.loop