Use wall clock to determine gap between notify calls
@@ -298,6 +298,7 @@ class Server:
self.started = False
self.should_exit = False
self.force_exit = False
+ self.last_notified = 0
def run(self, sockets=None, shutdown_servers=True):
self.config.setup_event_loop()
@@ -401,7 +402,8 @@ class Server:
# Callback to `callback_notify` once every `timeout_notify` seconds.
if self.config.callback_notify is not None:
- if counter % (10 * self.config.timeout_notify) == 0:
+ if current_time - self.last_notified > self.config.timeout_notify:
+ self.last_notified = current_time
await self.config.callback_notify()
# Determine if we should exit.
