예제 #1
0
 def refreshconn(self):
     # TODO: better algorithm
     f = lambda r: 1.0 / (1 + r.latency ** 2)
     next_conn = weighted_choice(self.recvs, f)
     next_conn.latency += 100  # Avoid repetition
     self.ready.preferred = False
     self.ready = next_conn
     next_conn.preferred = True
예제 #2
0
 def refreshconn(self):
     # TODO: better algorithm
     f = lambda r: 1.0 / (1 + r.latency ** 2)
     recvs_avail = list(
         filter(lambda _: _ is not None, self.serverreceivers_pool))
     next_conn = weighted_choice(recvs_avail, f)
     next_conn.latency += 100  # Avoid repetition
     self.ready.preferred = False
     self.ready = next_conn
     next_conn.preferred = True
예제 #3
0
 def refreshconn(self):
     # TODO: better algorithm
     f = lambda r: 1.0 / (1 + r.latency**2)
     recvs_avail = list(
         filter(lambda _: _ is not None, self.serverreceivers_pool))
     next_conn = weighted_choice(recvs_avail, f)
     next_conn.latency += 100  # Avoid repetition
     self.ready.preferred = False
     self.ready = next_conn
     next_conn.preferred = True