Don't return 0 as "time until next ping" when we've already sent a ping. return

None instead.
This commit is contained in:
jesopo 2018-09-11 18:25:27 +01:00
parent 788ba239e5
commit 58bc741177
2 changed files with 5 additions and 1 deletions

View file

@ -95,7 +95,9 @@ class Bot(object):
def next_ping(self): def next_ping(self):
timeouts = [] timeouts = []
for server in self.servers.values(): for server in self.servers.values():
timeouts.append(server.until_next_ping()) timeout = server.until_next_ping()
if not timeout == None:
timeouts.append(timeout)
if not timeouts: if not timeouts:
return None return None
return min(timeouts) return min(timeouts)

View file

@ -228,6 +228,8 @@ class Server(object):
return decoded_lines return decoded_lines
def until_next_ping(self): def until_next_ping(self):
if self.ping_sent:
return None
return max(0, (self.last_read+PING_INTERVAL_SECONDS return max(0, (self.last_read+PING_INTERVAL_SECONDS
)-time.monotonic()) )-time.monotonic())
def ping_due(self): def ping_due(self):