Skip to content
Permalink
Browse files

Avoid unnecesary disk writes

  • Loading branch information
sfan5 committed Mar 15, 2021
1 parent 9f144f3 commit a9ecf55b389d094e4ca7313d73c3b44f984c3a5b
Showing with 5 additions and 2 deletions.
  1. +5 −2 server.py
@@ -381,9 +381,12 @@ def server_points(server):
self.list.sort(key=server_points, reverse=True)

def purgeOld(self):
cutoff = int(time.time()) - app.config["PURGE_TIME"]
with self.lock:
self.list = [server for server in self.list if time.time() <= server["update_time"] + app.config["PURGE_TIME"]]
self.save()
count = len(self.list)
self.list = [server for server in self.list if cutoff <= server["update_time"]]
if len(self.list) < count:
self.save()

def load(self):
with self.lock:

0 comments on commit a9ecf55

Please sign in to comment.