def listen(self):
        seeklock = threading.Lock()
        cowfiles = []

        while True:
            try:
                conn, addr = self.sock.accept()

                # split off on a thread, allows us to handle multiple clients
                dispatch = threading.Thread(target = self.handle_client, args = (conn, addr, seeklock))

                # clients don't necessarily close the TCP connection
                # so we use this to kill the program on ctrl-c
                dispatch.daemon = True
                dispatch.start()

                # this is for the cleanup at the end. Will need clarifying
                # if MemCOW
                if self.cow and not self.in_mem:
                    cowfiles.append('PyPXE_NBD_COW_{addr[0]}_{addr[1]}'.format(addr = addr))
            except KeyboardInterrupt:
                map(os.remove, cowfiles)
                return
This method is the main loop that listens for requests.
dataset/ETHPy150Open psychomario/PyPXE/pypxe/nbd/nbd.py/NBD.listen