Update peer.py

This commit is contained in:
Aryan Singh committed 2026-09-27 02:51:21 -05:00
1 parent 1673aa567d
commit 8b3a4a98aa
1 file changed
+21 -6
+21 -6
View File
@@ -32,9 +32,9 @@ GLOBAL_PORT = 8989
MY_IP = socket.gethostbyname(socket.gethostname())
HEARTBEAT_INTERVAL = 0.25
GOSSIP_INTERVAL = 0.15
GOSSIP_INTERVAL = 0.10
JOIN_RETRY_INTERVAL = 1.0
GOSSIP_FANOUT = 1
GOSSIP_FANOUT = 2
GOSSIP_FAILURE_TIMEOUT = 2.8
GOSSIP_S_SUSPECT_TIMEOUT = 1
@@ -520,13 +520,28 @@ def cmd_display_suspects():
# THREAD 6 - Display membership list in a pretty format
def worker_monitor():
while not stop_threads.is_set():
with members_list_lock:
snapshot = dict(members_list)
snapshot = {
member_id: member_data.copy()
for member_id, member_data in members_list.items()
}
with cluster_state_lock:
mode = cluster_state["mode"]
drop_rate = cluster_state["drop_rate"]
try:
with open("membership_list.txt", "w") as f:
for m_id, m_data in snapshot.items():
f.write(f"{m_id}: {m_data}\n")
except Exception:
for member_id, member_data in snapshot.items():
f.write(f"{member_id}: {member_data}\n")
f.write(
f"Mode: {mode}, "
f"Drop Rate: {drop_rate}\n"
)
except Exception as e:
pass
time.sleep(0.5)