def listen(self):
        '''This method is the main loop that listens for requests.'''
        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 __HOLE__:
                map(os.remove, cowfiles)
                return
dataset/ETHPy150Open psychomario/PyPXE/pypxe/nbd/nbd.py/NBD.listen