human
Complete this python program:
def add_accept_handler(sock, callback, io_loop=None):
assistant
#Here is the Python code you requested.

    """Adds an `.IOLoop` event handler to accept new connections on ``sock``.
    When a connection is accepted, ``callback(connection, address)`` will
    be run (``connection`` is a socket object, and ``address`` is the
    address of the other end of the connection).  Note that this signature
    is different from the ``callback(fd, events)`` signature used for
    `.IOLoop` handlers.
    """
    if (io_loop is None):
        io_loop = IOLoop.current()
    def accept_handler(fd, events):
        while True:
            try:
                (connection, address) = sock.accept()
            except socket.error as e:
                if (e.args[0] in (errno.EWOULDBLOCK, errno.EAGAIN)):
                    return
                if (e.args[0] == errno.ECONNABORTED):
                    continue
                raise
            callback(connection, address)
    io_loop.add_handler(sock.fileno(), accept_handler, IOLoop.READ)