diff --git a/MP2/peer.py b/MP2/peer.py index 859237e..00af6d9 100644 --- a/MP2/peer.py +++ b/MP2/peer.py @@ -38,16 +38,14 @@ def worker_1(): "type": "JOIN", "sender_id": SELF_ID } + time.sleep(5) #just so the introducer has time to start the socket server_socket.sendto(json.dumps(join_payload).encode('utf-8'), (INTRODUCER_IP, SERVER_PORT)) while not stop_event.is_set(): try: data, addr = server_socket.recvfrom(65535) - try: - msg = json.loads(data.decode('utf-8')) - except json.JSONDecodeError: - continue + msg = json.loads(data.decode('utf-8')) msg_type = msg.get("type") print(f"Processing message type={msg_type} from {addr}") @@ -75,7 +73,7 @@ def worker_1(): print(f"New member joined: {join_id}") - # Send the initial state directly to the joining node + # Send the initial state directly to the joining node - decreases the overhead of having that init state propogate through the cluster reply_payload = { "type": "GOSSIP", "sender_id": SELF_ID,