from src.state.follower import Follower from src.state.candidate import Candidate server_list = [] ids = [i for i in range(1, 6)] threads = [] server_list = [] for i, id in enumerate(ids): if i == 0: t = threading.Thread( target=server_list.append, args=(Server(str(id), [{ "action": None, "term": 0, }], Follower(None), [str(_) for _ in ids[:i] + ids[i + 1:]], 0.15), )) t.start() else: t = threading.Thread( target=server_list.append, args=(Server(str(id), [{ "action": None, "term": 0, }], Follower(None), [str(_) for _ in ids[:i] + ids[i + 1:]]), )) t.start() threads.append(t) for thread in threads: thread.join()
log_status = int(sys.argv[3]) complete_test_log = [ { "action":None, "term":0, }, { "action":{'key':1,'value':1}, "term":0, }, { "action":{'key':1,'value':1}, "term":0, }, { "action":{'key':1,'value':1}, "term":0, }, ] ids = [] ids = [i for i in range(1,6)] for i,id in enumerate(ids): if str(id) == sys.argv[1]: Server(sys.argv[1], complete_test_log[:log_status+1], Follower(None), [str(_) for _ in ids[:i]+ids[i+1:]],)