Finally made this into a timer

This commit is contained in:
Dominik V. Salonen 2016-02-01 11:46:44 +01:00
parent a9b69265f1
commit af5a30ee13
1 changed files with 4 additions and 7 deletions

11
run.py
View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3
from flask import Flask, request, redirect, url_for, send_from_directory, abort, render_template
from werkzeug import secure_filename
from threading import Thread
from threading import Thread, Timer
import logging
import os
import random
@ -30,11 +30,8 @@ log.setLevel(logging.ERROR)
def cleaner_thread():
# TODO: Make this into a less shitty timer
while True:
print_log('Notice', 'Cleaner started')
delete_old()
time.sleep(config["CLEAN_INTERVAL"])
print_log('Notice', 'Cleaner started')
delete_old()
def delete_old():
@ -172,7 +169,7 @@ def nginx_error(error):
return error_page(error="We literally have no idea what just happened", code="Unknown")
cleaner = Thread(target = cleaner_thread, )
cleaner = Timer(config["CLEAN_INTERVAL"], cleaner_thread)
cleaner.start()
if __name__ == '__main__':
app.run(