def loop(conn):
    """The main loop."""

    def process():
        try:
            conn.Process(1)
        except KeyboardInterrupt:
            return 0
        return 1

    while process():
        pass