Commit 3b39b6b0 authored by Roman Haefeli's avatar Roman Haefeli
Browse files

do not remove elemts from dict while iterating over it

parent 0292a93d
......@@ -41,12 +41,13 @@ class Many2ManyBiProxy(threading.Thread):
continue
self.active_endpoints[my_addr] = time.time()
if self.heartbeat_sequence != my_data[:len(self.heartbeat_sequence)]:
for addr in self.active_endpoints.keys():
if addr != my_addr:
if (self.active_endpoints[addr] + self.timeout) < time.time():
del self.active_endpoints[addr]
else:
self.sock.sendto(my_data, addr)
other_clients = list(self.active_endpoints.keys())
other_clients.remove(my_addr)
for addr in other_clients:
if (self.active_endpoints[addr] + self.timeout) < time.time():
del self.active_endpoints[addr]
else:
self.sock.sendto(my_data, addr)
def stop(self):
self.kill_signal = True
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment