Schedule purging using plain python, obviating the need for APScheduler

This commit is contained in:
nOOb3167
2018-03-20 04:11:04 -04:00
committed by sfan5
parent f43f201af5
commit 48020105af
2 changed files with 10 additions and 9 deletions

View File

@@ -1,3 +1,2 @@
APScheduler>=3
Flask>=0.10

View File

@@ -2,14 +2,9 @@
import os, re, sys, json, time, socket
from threading import Thread, RLock
from apscheduler.schedulers.background import BackgroundScheduler
from flask import Flask, request, send_from_directory
# Set up scheduler
sched = BackgroundScheduler(timezone="UTC")
sched.start()
app = Flask(__name__, static_url_path = "")
# Load configuration
@@ -396,11 +391,18 @@ class ServerList:
self.sort()
self.save()
class PurgeThread(Thread):
def __init__(self):
Thread.__init__(self)
self.daemon = True
def run(self):
while True:
time.sleep(60)
serverList.purgeOld()
serverList = ServerList()
sched.add_job(lambda: serverList.purgeOld(), "interval",
seconds=60, coalesce=True, max_instances=1)
PurgeThread().start()
if __name__ == "__main__":
app.run(host = app.config["HOST"], port = app.config["PORT"])