def run_client(**kwargs): """Run the simulation client manager.""" save = kwargs.get("save", False) timeout = kwargs.get("timeout", 310) address = kwargs.get("address", ("127.0.0.1", 50000)) authkey = kwargs.get("authkey", None) n_procs = kwargs.get("n_procs", mp.cpu_count()) max_tries = kwargs.get("max_tries", 3) # Job-specific parameters. kwargs = dict(save=save) # Connect to the server manager ServerManager.register_shared(with_callable=False) mgr = ServerManager(address=address, authkey=authkey) mgr.connect() # create a lock for printing information info_lock = mp.Lock() # Set up params and task parameters. worker_kwargs = {'timeout': timeout, 'save': save, 'max_tries': max_tries} logger.info("Starting processes...") threads = [] for ithread in xrange(n_procs): thread = Thread(name="Thread_%02d" % ithread, target=worker_thread, args=(mgr, info_lock), kwargs=worker_kwargs) threads.append(thread) thread.start() thread.join(timeout=0.2) for thread in threads: thread.join() logger.info("Jobs complete.") sys.exit(0)