Update peer.py
This commit is contained in:
1 parent
db037f4f42
commit
ce0cec697c
1 file changed
+2
-4
+2
-4
@@ -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_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,
|
||||
|
||||
Reference in new issue
Block a user