Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Avoid unnecesary disk writes
  • Loading branch information
sfan5 committed Mar 15, 2021
1 parent 9f144f3 commit a9ecf55
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions server.py
Expand Up @@ -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:
Expand Down

0 comments on commit a9ecf55

Please sign in to comment.