Fix cleaner

This commit is contained in:
Dominik V. Salonen 2016-02-02 21:06:25 +01:00
parent 3d59f949cf
commit f67c6c0100
1 changed files with 10 additions and 5 deletions

15
run.py
View File

@ -31,6 +31,13 @@ log.setLevel(logging.ERROR)
def cleaner_thread(): def cleaner_thread():
print_log('Notice', 'Cleaner started') print_log('Notice', 'Cleaner started')
# Call itself again after the interval
cleaner = Timer(config["CLEAN_INTERVAL"], cleaner_thread)
cleaner.daemon = True # Daemons will attempt to exit cleanly along with the main process, which we want
cleaner.start()
# Actual function
delete_old() delete_old()
@ -169,13 +176,11 @@ def nginx_error(error):
return error_page(error="We literally have no idea what just happened", code="Unknown") return error_page(error="We literally have no idea what just happened", code="Unknown")
cleaner = Timer(config["CLEAN_INTERVAL"], cleaner_thread)
cleaner.start() cleaner_thread()
if __name__ == '__main__': if __name__ == '__main__':
app.run( app.run(
port=config["PORT"], port=config["PORT"],
host=config["HOST"], host=config["HOST"],
debug=config["DEBUG"] debug=config["DEBUG"]
) )
cleaner.cancel()
cleaner.join()