human
I wrote the below code

    io_loop = IOLoop.current()
    removed = [False]
    def accept_handler(fd, events):
        for i in xrange(_DEFAULT_BACKLOG):
            if removed[0]:
                return
            try:
                (connection, address) = sock.accept()
            except socket.error as e:
                if (errno_from_exception(e) in _ERRNO_WOULDBLOCK):
                    return
                if (errno_from_exception(e) == errno.ECONNABORTED):
                    continue
                raise
            set_close_exec(connection.fileno())
            callback(connection, address)
    def remove_handler():
        io_loop.remove_handler(sock)
        removed[0] = True
    io_loop.add_handler(sock, accept_handler, IOLoop.READ)
    return remove_handler

What's a good function header?
assistant
#Here's a good function header.

def add_accept_handler(sock, callback):