From ce0cec697c192e28d7ed9413282e4b8f643b8395 Mon Sep 17 00:00:00 2001 From: Aryan Singh Date: Fri, 25 Sep 2026 23:03:11 -0500 Subject: [PATCH] Update peer.py --- MP2/peer.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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,