Skip to content
Permalink
Browse files

Schedule purging using plain python, obviating the need for APScheduler

  • Loading branch information
nOOb3167 authored and sfan5 committed May 18, 2018
1 parent f43f201 commit 48020105afdec7dce714c9a74e036802f111008b
Showing with 10 additions and 9 deletions.
  1. +0 −1 requirements.txt
  2. +10 −8 server.py
@@ -1,3 +1,2 @@
APScheduler>=3
Flask>=0.10

@@ -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 @@ 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.