Skip to content

Commit

Permalink
Schedule purging using plain python, obviating the need for APScheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
nOOb3167 authored and sfan5 committed May 18, 2018
1 parent f43f201 commit 4802010
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
1 change: 0 additions & 1 deletion requirements.txt
@@ -1,3 +1,2 @@
APScheduler>=3
Flask>=0.10

18 changes: 10 additions & 8 deletions server.py
Expand Up @@ -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
Expand Down Expand Up @@ -396,11 +391,18 @@ def update(self, server):
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"])

0 comments on commit 4802010

Please sign in to comment.