def run_client(ip, port, authkey, max_items=None, timeout=<NUM_LIT:2>):
manager = make_client(ip, port, authkey)<EOL>job_q = manager.get_job_q()<EOL>job_q_closed = manager.q_closed()<EOL>result_q = manager.get_result_q()<EOL>function = manager.get_function()._getvalue()<EOL>processed = <NUM_LIT:0><EOL>while True:<EOL><INDENT>try:<EOL><INDENT>job = job_q.get_nowait()<EOL>result = function(job)<EOL>result_q.put(result)<EOL><DEDENT>except queue.Empty:<EOL><INDENT>if job_q_closed._getvalue().value:<EOL><INDENT>break<EOL><DEDENT><DEDENT>else:<EOL><INDENT>processed += <NUM_LIT:1><EOL>if max_items is not None and processed == max_items:<EOL><INDENT>break<EOL><DEDENT><DEDENT>sleep(timeout)<EOL><DEDENT>
Connect to a SwarmServer and do its dirty work.

    :param ip: ip address of server
    :param port: port to connect to on server
    :param authkey: authorization key
    :param max_items: maximum number of items to process from server.
        Useful for say running clients on a cluster.